Background

This file is designed to use CDC data to assess coronavirus disease burden by state, including creating and analyzing state-level clusters.

Through March 7, 2021, The COVID Tracking Project collected and integrated data on tests, cases, hospitalizations, deaths, and the like by state and date. The latest code for using this data is available in Coronavirus_Statistics_CTP_v004.Rmd.

The COVID Tracking Project suggest that US federal data sources are now sufficiently robust to be used for analyses that previously relied on COVID Tracking Project. This code is an attempt to update modules in Coronavirus_Statistics_CTP_v004.Rmd to leverage US federal data.

The code in this module builds on code available in _v004, with function and mapping files updated:

Broadly, the CDC data analyzed by this module includes:

Functions and Mapping Files

The tidyverse package is loaded and functions are sourced:

# The tidyverse functions are routinely used without package::function format
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
## ✔ ggplot2 3.3.6     ✔ purrr   0.3.4
## ✔ tibble  3.1.8     ✔ dplyr   1.0.9
## ✔ tidyr   1.2.0     ✔ stringr 1.4.0
## ✔ readr   2.1.2     ✔ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
library(geofacet)

# Functions are available in source file
source("./Generic_Added_Utility_Functions_202105_v001.R")
source("./Coronavirus_CDC_Daily_Functions_v002.R")

A series of mapping files are also available to allow for parameterized processing. Mappings include:

These default parameters are maintained in a separate .R file and can be sourced:

source("./Coronavirus_CDC_Daily_Default_Mappings_v002.R")

Example Code Processing

The function is run to download and process the latest CDC case, hospitalization, and death data:

readList <- list("cdcDaily"="./RInputFiles/Coronavirus/CDC_dc_downloaded_220907.csv", 
                 "cdcHosp"="./RInputFiles/Coronavirus/CDC_h_downloaded_220907.csv", 
                 "vax"="./RInputFiles/Coronavirus/vaxData_downloaded_220907.csv"
                 )
compareList <- list("cdcDaily"=readFromRDS("cdc_daily_220805")$dfRaw$cdcDaily, 
                    "cdcHosp"=readFromRDS("cdc_daily_220805")$dfRaw$cdcHosp, 
                    "vax"=readFromRDS("cdc_daily_220805")$dfRaw$vax
                    )

cdc_daily_220907 <- readRunCDCDaily(thruLabel="Sep 05, 2022", 
                                    downloadTo=lapply(readList, FUN=function(x) if(file.exists(x)) NA else x), 
                                    readFrom=readList,
                                    compareFile=compareList, 
                                    writeLog=NULL, 
                                    useClusters=readFromRDS("cdc_daily_210528")$useClusters, 
                                    weightedMeanAggs=c("tcpm7", "tdpm7", "cpm7", "dpm7", "hpm7", 
                                                       "vxcpm7", "vxcgte65pct"
                                                       ),
                                    skipAssessmentPlots=FALSE, 
                                    brewPalette="Paired"
                                    )
## Rows: 57480 Columns: 15
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr  (5): submission_date, state, created_at, consent_cases, consent_deaths
## dbl (10): tot_cases, conf_cases, prob_cases, new_case, pnew_case, tot_death,...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
## 
## *** File has been checked for uniqueness by: state date

## 
## 
## Checking for similarity of: column names
## In reference but not in current: 
## In current but not in reference: 
## 
## Checking for similarity of: date
## In reference but not in current: 0
## In current but not in reference: 33
## 
## Checking for similarity of: state
## In reference but not in current: 
## In current but not in reference:

## 
## 
## ***Differences of at least 5 and at least 5%
## 
##          date       name newValue refValue absDelta   pctDelta
## 1  2022-07-31 new_deaths      116       23       93 1.33812950
## 2  2022-07-30 new_deaths      130       34       96 1.17073171
## 3  2022-07-23 new_deaths      158      109       49 0.36704120
## 4  2022-07-24 new_deaths      170      126       44 0.29729730
## 5  2022-08-01 new_deaths      433      347       86 0.22051282
## 6  2022-07-28 new_deaths      518      434       84 0.17647059
## 7  2022-07-16 new_deaths      151      127       24 0.17266187
## 8  2022-07-29 new_deaths      639      543       96 0.16243655
## 9  2022-07-25 new_deaths      306      265       41 0.14360771
## 10 2022-08-03 new_deaths      716      632       84 0.12462908
## 11 2022-08-02 new_deaths      715      632       83 0.12323682
## 12 2022-07-27 new_deaths      703      634       69 0.10321616
## 13 2022-07-10 new_deaths      114      103       11 0.10138249
## 14 2022-07-22 new_deaths      628      580       48 0.07947020
## 15 2022-06-18 new_deaths      105       97        8 0.07920792
## 16 2022-07-26 new_deaths      643      596       47 0.07586764
## 17 2022-07-04 new_deaths      138      128       10 0.07518797
## 18 2022-07-18 new_deaths      361      337       24 0.06876791
## 19 2022-07-21 new_deaths      500      471       29 0.05973223
## 20 2022-07-09 new_deaths      110      104        6 0.05607477
## 21 2022-07-30  new_cases    38338    32823     5515 0.15500063
## 22 2022-07-31  new_cases    39803    35276     4527 0.12059298
## 23 2022-08-01  new_cases   126242   133013     6771 0.05223429

## 
## 
## ***Differences of at least 0 and at least 0.1%
## 
##    state       name newValue refValue absDelta    pctDelta
## 1     NC tot_deaths 11352019 11325521    26498 0.002336938
## 2     KY tot_deaths  6954858  6939424    15434 0.002221633
## 3     NC new_deaths    26101    25692      409 0.015793640
## 4     KY new_deaths    16647    16438      209 0.012634124
## 5     FL new_deaths    78609    77823      786 0.010049095
## 6     AL new_deaths    20081    19974      107 0.005342654
## 7     SC new_deaths    18211    18192       19 0.001043870
## 8     SC  new_cases  1626423  1605165    21258 0.013156380
## 9     KY  new_cases  1489715  1479668    10047 0.006767062
## 10    NC  new_cases  3026839  3022204     4635 0.001532474
## 
## 
## 
## Raw file for cdcDaily:
## Rows: 57,480
## Columns: 15
## $ date           <date> 2021-03-11, 2021-12-01, 2022-01-02, 2021-09-01, 2021-0…
## $ state          <chr> "KS", "ND", "AS", "ND", "IN", "FL", "TN", "PR", "PW", "…
## $ tot_cases      <dbl> 297229, 163565, 11, 118491, 668765, 3510205, 64885, 173…
## $ conf_cases     <dbl> 241035, 135705, NA, 107475, NA, NA, 64371, 144788, NA, …
## $ prob_cases     <dbl> 56194, 27860, NA, 11016, NA, NA, 514, 29179, NA, NA, NA…
## $ new_cases      <dbl> 0, 589, 0, 536, 487, 9979, 1816, 667, 0, 317, 0, 28, 8,…
## $ pnew_case      <dbl> 0, 220, 0, 66, 0, 2709, 30, 274, 0, 0, 0, 5, 0, 46, 70,…
## $ tot_deaths     <dbl> 4851, 1907, 0, 1562, 12710, 56036, 749, 2911, 0, 561, 0…
## $ conf_death     <dbl> NA, NA, NA, NA, 12315, NA, 722, 2482, NA, NA, NA, 1601,…
## $ prob_death     <dbl> NA, NA, NA, NA, 395, NA, 27, 429, NA, NA, NA, 366, NA, …
## $ new_deaths     <dbl> 0, 9, 0, 1, 7, 294, 8, 8, 0, 12, 0, 0, 0, 5, 0, 4, 0, 0…
## $ pnew_death     <dbl> 0, 0, 0, 0, 2, 26, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …
## $ created_at     <chr> "03/12/2021 03:20:13 PM", "12/02/2021 02:35:20 PM", "01…
## $ consent_cases  <chr> "Agree", "Agree", NA, "Agree", "Not agree", "Not agree"…
## $ consent_deaths <chr> "N/A", "Not agree", NA, "Not agree", "Agree", "Not agre…
## Rows: 49367 Columns: 135
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr    (1): state
## dbl  (132): critical_staffing_shortage_today_yes, critical_staffing_shortage...
## lgl    (1): geocoded_state
## date   (1): date
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.

## 
## *** File has been checked for uniqueness by: state date

## 
## 
## Checking for similarity of: column names
## In reference but not in current: 
## In current but not in reference: 
## 
## Checking for similarity of: date
## In reference but not in current: 0
## In current but not in reference: 33
## 
## Checking for similarity of: state
## In reference but not in current: 
## In current but not in reference:

## 
## 
## ***Differences of at least 5 and at least 5%
## 
##         date     name newValue refValue absDelta  pctDelta
## 1 2020-07-25 hosp_ped     3964     4594      630 0.1472307

## 
## 
## ***Differences of at least 0 and at least 0.1%
## 
##    state       name newValue refValue absDelta    pctDelta
## 1     ND        inp   122358   122070      288 0.002356522
## 2     NH   hosp_ped     1127     1167       40 0.034873583
## 3     KS   hosp_ped     4891     4725      166 0.034525790
## 4     ME   hosp_ped     2387     2338       49 0.020740741
## 5     KY   hosp_ped    20285    20665      380 0.018559219
## 6     WV   hosp_ped     5686     5753       67 0.011714311
## 7     VA   hosp_ped    18388    18192      196 0.010716238
## 8     TN   hosp_ped    22215    22423      208 0.009319414
## 9     NM   hosp_ped     8054     8114       60 0.007422068
## 10    SC   hosp_ped     9035     9092       57 0.006288961
## 11    DE   hosp_ped     5277     5310       33 0.006234061
## 12    NJ   hosp_ped    19499    19618      119 0.006084311
## 13    UT   hosp_ped    10271    10210       61 0.005956740
## 14    MS   hosp_ped    11803    11854       51 0.004311620
## 15    AL   hosp_ped    20947    21025       78 0.003716764
## 16    VT   hosp_ped      540      542        2 0.003696858
## 17    WY   hosp_ped      859      856        3 0.003498542
## 18    MA   hosp_ped    12619    12657       38 0.003006805
## 19    NC   hosp_ped    30541    30453       88 0.002885530
## 20    PR   hosp_ped    23021    22959       62 0.002696825
## 21    IL   hosp_ped    44084    44202      118 0.002673131
## 22    AK   hosp_ped     2664     2657        7 0.002631084
## 23    MO   hosp_ped    39841    39939       98 0.002456756
## 24    PA   hosp_ped    55078    55211      133 0.002411845
## 25    AR   hosp_ped    12767    12747       20 0.001567767
## 26    CO   hosp_ped    22421    22387       34 0.001517586
## 27    OH   hosp_ped    91382    91261      121 0.001324989
## 28    AZ   hosp_ped    27563    27532       31 0.001125329
## 29    MD   hosp_ped    17240    17221       19 0.001102696
## 30    ND hosp_adult   115920   115630      290 0.002504859
## 
## 
## 
## Raw file for cdcHosp:
## Rows: 49,367
## Columns: 135
## $ state                                                                        <chr> …
## $ date                                                                         <date> …
## $ critical_staffing_shortage_today_yes                                         <dbl> …
## $ critical_staffing_shortage_today_no                                          <dbl> …
## $ critical_staffing_shortage_today_not_reported                                <dbl> …
## $ critical_staffing_shortage_anticipated_within_week_yes                       <dbl> …
## $ critical_staffing_shortage_anticipated_within_week_no                        <dbl> …
## $ critical_staffing_shortage_anticipated_within_week_not_reported              <dbl> …
## $ hospital_onset_covid                                                         <dbl> …
## $ hospital_onset_covid_coverage                                                <dbl> …
## $ inpatient_beds                                                               <dbl> …
## $ inpatient_beds_coverage                                                      <dbl> …
## $ inpatient_beds_used                                                          <dbl> …
## $ inpatient_beds_used_coverage                                                 <dbl> …
## $ inp                                                                          <dbl> …
## $ inpatient_beds_used_covid_coverage                                           <dbl> …
## $ previous_day_admission_adult_covid_confirmed                                 <dbl> …
## $ previous_day_admission_adult_covid_confirmed_coverage                        <dbl> …
## $ previous_day_admission_adult_covid_suspected                                 <dbl> …
## $ previous_day_admission_adult_covid_suspected_coverage                        <dbl> …
## $ previous_day_admission_pediatric_covid_confirmed                             <dbl> …
## $ previous_day_admission_pediatric_covid_confirmed_coverage                    <dbl> …
## $ previous_day_admission_pediatric_covid_suspected                             <dbl> …
## $ previous_day_admission_pediatric_covid_suspected_coverage                    <dbl> …
## $ staffed_adult_icu_bed_occupancy                                              <dbl> …
## $ staffed_adult_icu_bed_occupancy_coverage                                     <dbl> …
## $ staffed_icu_adult_patients_confirmed_and_suspected_covid                     <dbl> …
## $ staffed_icu_adult_patients_confirmed_and_suspected_covid_coverage            <dbl> …
## $ staffed_icu_adult_patients_confirmed_covid                                   <dbl> …
## $ staffed_icu_adult_patients_confirmed_covid_coverage                          <dbl> …
## $ hosp_adult                                                                   <dbl> …
## $ total_adult_patients_hospitalized_confirmed_and_suspected_covid_coverage     <dbl> …
## $ total_adult_patients_hospitalized_confirmed_covid                            <dbl> …
## $ total_adult_patients_hospitalized_confirmed_covid_coverage                   <dbl> …
## $ hosp_ped                                                                     <dbl> …
## $ total_pediatric_patients_hospitalized_confirmed_and_suspected_covid_coverage <dbl> …
## $ total_pediatric_patients_hospitalized_confirmed_covid                        <dbl> …
## $ total_pediatric_patients_hospitalized_confirmed_covid_coverage               <dbl> …
## $ total_staffed_adult_icu_beds                                                 <dbl> …
## $ total_staffed_adult_icu_beds_coverage                                        <dbl> …
## $ inpatient_beds_utilization                                                   <dbl> …
## $ inpatient_beds_utilization_coverage                                          <dbl> …
## $ inpatient_beds_utilization_numerator                                         <dbl> …
## $ inpatient_beds_utilization_denominator                                       <dbl> …
## $ percent_of_inpatients_with_covid                                             <dbl> …
## $ percent_of_inpatients_with_covid_coverage                                    <dbl> …
## $ percent_of_inpatients_with_covid_numerator                                   <dbl> …
## $ percent_of_inpatients_with_covid_denominator                                 <dbl> …
## $ inpatient_bed_covid_utilization                                              <dbl> …
## $ inpatient_bed_covid_utilization_coverage                                     <dbl> …
## $ inpatient_bed_covid_utilization_numerator                                    <dbl> …
## $ inpatient_bed_covid_utilization_denominator                                  <dbl> …
## $ adult_icu_bed_covid_utilization                                              <dbl> …
## $ adult_icu_bed_covid_utilization_coverage                                     <dbl> …
## $ adult_icu_bed_covid_utilization_numerator                                    <dbl> …
## $ adult_icu_bed_covid_utilization_denominator                                  <dbl> …
## $ adult_icu_bed_utilization                                                    <dbl> …
## $ adult_icu_bed_utilization_coverage                                           <dbl> …
## $ adult_icu_bed_utilization_numerator                                          <dbl> …
## $ adult_icu_bed_utilization_denominator                                        <dbl> …
## $ geocoded_state                                                               <lgl> …
## $ `previous_day_admission_adult_covid_confirmed_18-19`                         <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_18-19_coverage`                <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_20-29`                         <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_20-29_coverage`                <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_30-39`                         <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_30-39_coverage`                <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_40-49`                         <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_40-49_coverage`                <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_50-59`                         <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_50-59_coverage`                <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_60-69`                         <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_60-69_coverage`                <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_70-79`                         <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_70-79_coverage`                <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_80+`                           <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_80+_coverage`                  <dbl> …
## $ previous_day_admission_adult_covid_confirmed_unknown                         <dbl> …
## $ previous_day_admission_adult_covid_confirmed_unknown_coverage                <dbl> …
## $ `previous_day_admission_adult_covid_suspected_18-19`                         <dbl> …
## $ `previous_day_admission_adult_covid_suspected_18-19_coverage`                <dbl> …
## $ `previous_day_admission_adult_covid_suspected_20-29`                         <dbl> …
## $ `previous_day_admission_adult_covid_suspected_20-29_coverage`                <dbl> …
## $ `previous_day_admission_adult_covid_suspected_30-39`                         <dbl> …
## $ `previous_day_admission_adult_covid_suspected_30-39_coverage`                <dbl> …
## $ `previous_day_admission_adult_covid_suspected_40-49`                         <dbl> …
## $ `previous_day_admission_adult_covid_suspected_40-49_coverage`                <dbl> …
## $ `previous_day_admission_adult_covid_suspected_50-59`                         <dbl> …
## $ `previous_day_admission_adult_covid_suspected_50-59_coverage`                <dbl> …
## $ `previous_day_admission_adult_covid_suspected_60-69`                         <dbl> …
## $ `previous_day_admission_adult_covid_suspected_60-69_coverage`                <dbl> …
## $ `previous_day_admission_adult_covid_suspected_70-79`                         <dbl> …
## $ `previous_day_admission_adult_covid_suspected_70-79_coverage`                <dbl> …
## $ `previous_day_admission_adult_covid_suspected_80+`                           <dbl> …
## $ `previous_day_admission_adult_covid_suspected_80+_coverage`                  <dbl> …
## $ previous_day_admission_adult_covid_suspected_unknown                         <dbl> …
## $ previous_day_admission_adult_covid_suspected_unknown_coverage                <dbl> …
## $ deaths_covid                                                                 <dbl> …
## $ deaths_covid_coverage                                                        <dbl> …
## $ on_hand_supply_therapeutic_a_casirivimab_imdevimab_courses                   <dbl> …
## $ on_hand_supply_therapeutic_b_bamlanivimab_courses                            <dbl> …
## $ on_hand_supply_therapeutic_c_bamlanivimab_etesevimab_courses                 <dbl> …
## $ previous_week_therapeutic_a_casirivimab_imdevimab_courses_used               <dbl> …
## $ previous_week_therapeutic_b_bamlanivimab_courses_used                        <dbl> …
## $ previous_week_therapeutic_c_bamlanivimab_etesevimab_courses_used             <dbl> …
## $ icu_patients_confirmed_influenza                                             <dbl> …
## $ icu_patients_confirmed_influenza_coverage                                    <dbl> …
## $ previous_day_admission_influenza_confirmed                                   <dbl> …
## $ previous_day_admission_influenza_confirmed_coverage                          <dbl> …
## $ previous_day_deaths_covid_and_influenza                                      <dbl> …
## $ previous_day_deaths_covid_and_influenza_coverage                             <dbl> …
## $ previous_day_deaths_influenza                                                <dbl> …
## $ previous_day_deaths_influenza_coverage                                       <dbl> …
## $ total_patients_hospitalized_confirmed_influenza                              <dbl> …
## $ total_patients_hospitalized_confirmed_influenza_and_covid                    <dbl> …
## $ total_patients_hospitalized_confirmed_influenza_and_covid_coverage           <dbl> …
## $ total_patients_hospitalized_confirmed_influenza_coverage                     <dbl> …
## $ all_pediatric_inpatient_bed_occupied                                         <dbl> …
## $ all_pediatric_inpatient_bed_occupied_coverage                                <dbl> …
## $ all_pediatric_inpatient_beds                                                 <dbl> …
## $ all_pediatric_inpatient_beds_coverage                                        <dbl> …
## $ previous_day_admission_pediatric_covid_confirmed_0_4                         <dbl> …
## $ previous_day_admission_pediatric_covid_confirmed_0_4_coverage                <dbl> …
## $ previous_day_admission_pediatric_covid_confirmed_12_17                       <dbl> …
## $ previous_day_admission_pediatric_covid_confirmed_12_17_coverage              <dbl> …
## $ previous_day_admission_pediatric_covid_confirmed_5_11                        <dbl> …
## $ previous_day_admission_pediatric_covid_confirmed_5_11_coverage               <dbl> …
## $ previous_day_admission_pediatric_covid_confirmed_unknown                     <dbl> …
## $ previous_day_admission_pediatric_covid_confirmed_unknown_coverage            <dbl> …
## $ staffed_icu_pediatric_patients_confirmed_covid                               <dbl> …
## $ staffed_icu_pediatric_patients_confirmed_covid_coverage                      <dbl> …
## $ staffed_pediatric_icu_bed_occupancy                                          <dbl> …
## $ staffed_pediatric_icu_bed_occupancy_coverage                                 <dbl> …
## $ total_staffed_pediatric_icu_beds                                             <dbl> …
## $ total_staffed_pediatric_icu_beds_coverage                                    <dbl> …
## Rows: 36184 Columns: 96
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr  (2): Date, Location
## dbl (94): MMWR_week, Distributed, Distributed_Janssen, Distributed_Moderna, ...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.

## 
## *** File has been checked for uniqueness by: state date

## 
## 
## Checking for similarity of: column names
## In reference but not in current: 
## In current but not in reference: Distributed_Novavax Administered_Novavax Series_Complete_Novavax
## 
## Checking for similarity of: date
## In reference but not in current: 0
## In current but not in reference: 4
## 
## Checking for similarity of: state
## In reference but not in current: 
## In current but not in reference:

## 
## 
## ***Differences of at least 1 and at least 1%
## 
## [1] date     name     newValue refValue absDelta pctDelta
## <0 rows> (or 0-length row.names)
## 
## 
## ***Differences of at least 0 and at least 0.1%
## 
## [1] state    name     newValue refValue absDelta pctDelta
## <0 rows> (or 0-length row.names)
## 
## 
## 
## Raw file for vax:
## Rows: 36,184
## Columns: 96
## $ date                                   <date> 2022-08-31, 2022-08-31, 2022-0…
## $ MMWR_week                              <dbl> 35, 35, 35, 35, 35, 35, 35, 35,…
## $ state                                  <chr> "PW", "SD", "MA", "HI", "RI", "…
## $ Distributed                            <dbl> 47090, 2141765, 18793570, 38391…
## $ Distributed_Janssen                    <dbl> 3800, 92800, 626200, 124700, 90…
## $ Distributed_Moderna                    <dbl> 30000, 847500, 7168380, 1461820…
## $ Distributed_Pfizer                     <dbl> 13290, 1199665, 10993590, 22498…
## $ Distributed_Novavax                    <dbl> 0, 1800, 5400, 2800, 3200, 200,…
## $ Distributed_Unk_Manuf                  <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0…
## $ Dist_Per_100K                          <dbl> 218698, 242101, 272667, 271153,…
## $ Distributed_Per_100k_5Plus             <dbl> 231139, 260083, 287577, 288518,…
## $ Distributed_Per_100k_12Plus            <dbl> 252561, 290172, 312354, 316997,…
## $ Distributed_Per_100k_18Plus            <dbl> 283966, 320836, 339252, 344011,…
## $ Distributed_Per_100k_65Plus            <dbl> 2363960, 1410250, 1607210, 1430…
## $ vxa                                    <dbl> 49416, 1511407, 15773792, 31561…
## $ Administered_5Plus                     <dbl> 49373, 1507671, 15687231, 31448…
## $ Administered_12Plus                    <dbl> 46683, 1451767, 15028043, 30184…
## $ Administered_18Plus                    <dbl> 43018, 1359766, 14038745, 28178…
## $ Administered_65Plus                    <dbl> 5346, 453691, 3769576, 842523, …
## $ Administered_Janssen                   <dbl> 2357, 42334, 407539, 71355, 664…
## $ Administered_Moderna                   <dbl> 37794, 586034, 6193704, 1157104…
## $ Administered_Pfizer                    <dbl> 9098, 882891, 9171774, 1927032,…
## $ Administered_Novavax                   <dbl> 0, 0, 295, 10, 219, 1, 45, 25, …
## $ Administered_Unk_Manuf                 <dbl> 167, 148, 480, 697, 2259, 9, 25…
## $ Admin_Per_100k                         <dbl> 229500, 170846, 228854, 222915,…
## $ Admin_Per_100k_5Plus                   <dbl> 242345, 183083, 240044, 236338,…
## $ Admin_Per_100k_12Plus                  <dbl> 250378, 196689, 249770, 249232,…
## $ Admin_Per_100k_18Plus                  <dbl> 259410, 203693, 253421, 252497,…
## $ Admin_Per_100k_65Plus                  <dbl> 268373, 298734, 322370, 313850,…
## $ Recip_Administered                     <dbl> 49797, 1533994, 15858274, 31873…
## $ Administered_Dose1_Recip               <dbl> 20575, 700878, 6982383, 1266721…
## $ Administered_Dose1_Pop_Pct             <dbl> 95.0, 79.2, 95.0, 89.5, 95.0, 8…
## $ Administered_Dose1_Recip_5Plus         <dbl> 20547, 698199, 6928829, 1259039…
## $ Administered_Dose1_Recip_5PlusPop_Pct  <dbl> 95.0, 84.8, 95.0, 94.6, 95.0, 9…
## $ Administered_Dose1_Recip_12Plus        <dbl> 19119, 668658, 6593289, 1196906…
## $ Administered_Dose1_Recip_12PlusPop_Pct <dbl> 95.0, 90.6, 95.0, 95.0, 95.0, 9…
## $ Administered_Dose1_Recip_18Plus        <dbl> 17584, 622099, 6127404, 1107067…
## $ Administered_Dose1_Recip_18PlusPop_Pct <dbl> 95.0, 93.2, 95.0, 95.0, 95.0, 9…
## $ Administered_Dose1_Recip_65Plus        <dbl> 1876, 182192, 1462735, 275645, …
## $ Administered_Dose1_Recip_65PlusPop_Pct <dbl> 94.2, 95.0, 95.0, 95.0, 95.0, 8…
## $ vxc                                    <dbl> 18338, 563276, 5570460, 1128707…
## $ vxcpoppct                              <dbl> 85.2, 63.7, 80.8, 79.7, 84.9, 8…
## $ Series_Complete_5Plus                  <dbl> 18330, 563050, 5551263, 1126786…
## $ Series_Complete_5PlusPop_Pct           <dbl> 90.0, 68.4, 84.9, 84.7, 89.4, 9…
## $ Series_Complete_12Plus                 <dbl> 17241, 539812, 5278994, 1071938…
## $ Series_Complete_12PlusPop_Pct          <dbl> 92.5, 73.1, 87.7, 88.5, 92.3, 9…
## $ vxcgte18                               <dbl> 15791, 503622, 4896487, 990569,…
## $ vxcgte18pct                            <dbl> 95.0, 75.4, 88.4, 88.8, 93.0, 9…
## $ vxcgte65                               <dbl> 1811, 151094, 1165453, 252765, …
## $ vxcgte65pct                            <dbl> 90.9, 95.0, 95.0, 94.2, 95.0, 8…
## $ Series_Complete_Janssen                <dbl> 2361, 39918, 384642, 66056, 611…
## $ Series_Complete_Moderna                <dbl> 12724, 204498, 1968460, 371324,…
## $ Series_Complete_Pfizer                 <dbl> 3164, 318781, 3216940, 691089, …
## $ Series_Complete_Novavax                <dbl> 0, 2, 38, 1, 52, 1, 6, 6, 38, 2…
## $ Series_Complete_Unk_Manuf              <dbl> 82, 70, 290, 215, 602, 3, 591, …
## $ Series_Complete_Janssen_5Plus          <dbl> 2361, 39914, 384637, 66028, 611…
## $ Series_Complete_Moderna_5Plus          <dbl> 12724, 204289, 1955713, 370535,…
## $ Series_Complete_Pfizer_5Plus           <dbl> 3163, 318775, 3210586, 690007, …
## $ Series_Complete_Unk_Manuf_5Plus        <dbl> 82, 70, 289, 215, 587, 3, 591, …
## $ Series_Complete_Janssen_12Plus         <dbl> 2361, 39912, 384612, 66026, 611…
## $ Series_Complete_Moderna_12Plus         <dbl> 12724, 204257, 1953836, 370413,…
## $ Series_Complete_Pfizer_12Plus          <dbl> 2074, 295572, 2940222, 635307, …
## $ Series_Complete_Unk_Manuf_12Plus       <dbl> 82, 69, 286, 191, 572, 3, 588, …
## $ Series_Complete_Janssen_18Plus         <dbl> 2361, 39882, 383306, 65839, 611…
## $ Series_Complete_Moderna_18Plus         <dbl> 12723, 204149, 1948279, 369555,…
## $ Series_Complete_Pfizer_18Plus          <dbl> 625, 259525, 2564603, 555015, 4…
## $ Series_Complete_Unk_Manuf_18Plus       <dbl> 82, 64, 262, 159, 543, 3, 574, …
## $ Series_Complete_Janssen_65Plus         <dbl> 227, 5079, 74665, 11821, 6832, …
## $ Series_Complete_Moderna_65Plus         <dbl> 1542, 74263, 531381, 111196, 86…
## $ Series_Complete_Pfizer_65Plus          <dbl> 40, 71727, 559321, 129727, 1005…
## $ Series_Complete_Unk_Manuf_65Plus       <dbl> 2, 25, 80, 21, 162, 0, 263, 69,…
## $ Additional_Doses                       <dbl> 12048, 248903, 2987198, 646528,…
## $ Additional_Doses_Vax_Pct               <dbl> 65.7, 44.2, 53.6, 57.3, 56.1, 5…
## $ Additional_Doses_5Plus                 <dbl> 12048, 248900, 2987162, 646515,…
## $ Additional_Doses_5Plus_Vax_Pct         <dbl> 65.7, 44.2, 53.8, 57.4, 56.2, 5…
## $ Additional_Doses_12Plus                <dbl> 11872, 246180, 2938665, 637193,…
## $ Additional_Doses_12Plus_Vax_Pct        <dbl> 68.9, 45.6, 55.7, 59.4, 58.4, 5…
## $ Additional_Doses_18Plus                <dbl> 11181, 236970, 2791202, 606621,…
## $ Additional_Doses_18Plus_Vax_Pct        <dbl> 70.8, 47.1, 57.0, 61.2, 60.1, 5…
## $ Additional_Doses_50Plus                <dbl> 4815, 163923, 1630617, 376685, …
## $ Additional_Doses_50Plus_Vax_Pct        <dbl> 80.1, 58.2, 66.0, 75.0, 71.4, 7…
## $ Additional_Doses_65Plus                <dbl> 1575, 98849, 840257, 208155, 15…
## $ Additional_Doses_65Plus_Vax_Pct        <dbl> 87.0, 65.4, 72.1, 82.4, 79.0, 7…
## $ Additional_Doses_Moderna               <dbl> 10870, 109000, 1349812, 272149,…
## $ Additional_Doses_Pfizer                <dbl> 1176, 136782, 1609614, 367759, …
## $ Additional_Doses_Janssen               <dbl> 2, 3093, 27721, 6500, 5296, 217…
## $ Additional_Doses_Unk_Manuf             <dbl> 0, 26, 45, 118, 129, 0, 438, 78…
## $ Second_Booster                         <dbl> NA, NA, NA, NA, NA, NA, NA, NA,…
## $ Second_Booster_50Plus                  <dbl> 1126, 53725, 590595, 170399, 10…
## $ Second_Booster_50Plus_Vax_Pct          <dbl> 23.4, 32.8, 36.2, 45.2, 34.4, 1…
## $ Second_Booster_65Plus                  <dbl> 383, 39382, 379347, 111314, 667…
## $ Second_Booster_65Plus_Vax_Pct          <dbl> 24.3, 39.8, 45.1, 53.5, 43.5, 2…
## $ Second_Booster_Janssen                 <dbl> 0, 27, 253, 120, 151, 1, 119, 2…
## $ Second_Booster_Moderna                 <dbl> 1148, 24919, 309097, 87335, 498…
## $ Second_Booster_Pfizer                  <dbl> 22, 30731, 314869, 91565, 57827…
## $ Second_Booster_Unk_Manuf               <dbl> 0, 2, 10, 15, 53, 0, 80, 28, 21…
## 
## Column sums before and after applying filtering rules:
## # A tibble: 3 × 6
##   isType tot_cases tot_deaths     new_cases    new_deaths         n
##   <chr>      <dbl>      <dbl>         <dbl>         <dbl>     <dbl>
## 1 before  3.53e+10    5.16e+8 93993694      1025546       56522    
## 2 after   3.51e+10    5.14e+8 92929415      1019927       48858    
## 3 pctchg  6.80e- 3    4.57e-3        0.0113       0.00548     0.136
## 
## 
## Processed for cdcDaily:
## Rows: 48,858
## Columns: 6
## $ date       <date> 2021-03-11, 2021-12-01, 2021-09-01, 2021-03-08, 2021-09-17…
## $ state      <chr> "KS", "ND", "ND", "IN", "FL", "TN", "IA", "SD", "HI", "MA",…
## $ tot_cases  <dbl> 297229, 163565, 118491, 668765, 3510205, 64885, 20015, 1226…
## $ tot_deaths <dbl> 4851, 1907, 1562, 12710, 56036, 749, 561, 1967, 17, 17818, …
## $ new_cases  <dbl> 0, 589, 536, 487, 9979, 1816, 317, 28, 8, 451, 1040, 133, 0…
## $ new_deaths <dbl> 0, 9, 1, 7, 294, 8, 12, 0, 0, 5, 4, 0, 0, 5, 1, 3, 0, 0, 22…
## 
## Column sums before and after applying filtering rules:
## # A tibble: 3 × 5
##   isType     inp hosp_adult     hosp_ped          n
##   <chr>    <dbl>      <dbl>        <dbl>      <dbl>
## 1 before 5.11e+7    4.45e+7 1229807      49367     
## 2 after  5.09e+7    4.43e+7 1205197      47181     
## 3 pctchg 5.37e-3    5.13e-3       0.0200     0.0443
## 
## 
## Processed for cdcHosp:
## Rows: 47,181
## Columns: 5
## $ date       <date> 2021-01-06, 2021-01-06, 2020-12-31, 2020-12-30, 2020-12-29…
## $ state      <chr> "MA", "OR", "SD", "RI", "OR", "OH", "LA", "WV", "VT", "WY",…
## $ inp        <dbl> 2232, 583, 282, 471, 626, 5534, 1461, 242, 0, 71, 1, 91, 49…
## $ hosp_adult <dbl> 2209, 568, 280, 469, 615, 5443, 1449, 241, 0, 70, 1, 90, 48…
## $ hosp_ped   <dbl> 23, 15, 2, 2, 11, 91, 12, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, …
## 
## Column sums before and after applying filtering rules:
## # A tibble: 3 × 9
##   isType      vxa      vxc   vxcpoppct vxcgte65 vxcgt…¹ vxcgte18 vxcgt…²       n
##   <chr>     <dbl>    <dbl>       <dbl>    <dbl>   <dbl>    <dbl>   <dbl>   <dbl>
## 1 before 4.14e+11 1.70e+11 1511640.    4.31e+10 2.24e+6 1.57e+11 1.78e+6 3.62e+4
## 2 after  2.00e+11 8.22e+10 1265373.    2.09e+10 1.98e+6 7.61e+10 1.51e+6 2.86e+4
## 3 pctchg 5.18e- 1 5.16e- 1       0.163 5.16e- 1 1.14e-1 5.16e- 1 1.54e-1 2.09e-1
## # … with abbreviated variable names ¹​vxcgte65pct, ²​vxcgte18pct
## 
## 
## Processed for vax:
## Rows: 28,611
## Columns: 9
## $ date        <date> 2022-08-31, 2022-08-31, 2022-08-31, 2022-08-31, 2022-08-3…
## $ state       <chr> "SD", "MA", "HI", "RI", "MT", "WY", "LA", "KS", "IN", "MS"…
## $ vxa         <dbl> 1511407, 15773792, 3156198, 2353711, 1675440, 778457, 6536…
## $ vxc         <dbl> 563276, 5570460, 1128707, 899544, 618143, 300240, 2526855,…
## $ vxcpoppct   <dbl> 63.7, 80.8, 79.7, 84.9, 57.8, 51.9, 54.4, 63.3, 56.8, 53.0…
## $ vxcgte65    <dbl> 151094, 1165453, 252765, 194268, 180238, 84688, 642150, 44…
## $ vxcgte65pct <dbl> 95.0, 95.0, 94.2, 95.0, 87.3, 85.4, 86.7, 94.6, 88.5, 85.2…
## $ vxcgte18    <dbl> 503622, 4896487, 990569, 794734, 562722, 275699, 2323648, …
## $ vxcgte18pct <dbl> 75.4, 88.4, 88.8, 93.0, 67.0, 62.0, 65.2, 74.2, 67.0, 63.3…
## 
## Integrated per capita data file:
## Rows: 49,071
## Columns: 34
## $ date        <date> 2020-01-01, 2020-01-01, 2020-01-01, 2020-01-01, 2020-01-0…
## $ state       <chr> "AL", "HI", "IN", "LA", "MN", "MT", "NC", "TX", "AL", "HI"…
## $ tot_cases   <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ tot_deaths  <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ new_cases   <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ new_deaths  <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ inp         <dbl> NA, 0, 0, NA, 0, 0, 0, 0, NA, 0, 0, NA, 0, 0, 0, 1877, 0, …
## $ hosp_adult  <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ hosp_ped    <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ vxa         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ vxc         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ vxcpoppct   <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ vxcgte65    <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ vxcgte65pct <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ vxcgte18    <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ vxcgte18pct <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ tcpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ tdpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ cpm         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ dpm         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ hpm         <dbl> NA, 0.0000, 0.0000, NA, 0.0000, 0.0000, 0.0000, 0.0000, NA…
## $ ahpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ phpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ vxapm       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ vxcpm       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ tcpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ tdpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ cpm7        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ dpm7        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ hpm7        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ ahpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ phpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ vxapm7      <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ vxcpm7      <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj =
## prefer_proj): Discarded datum unknown in Proj4 definition

saveToRDS(cdc_daily_220907, ovrWriteError=FALSE)

The function is run to download and process the latest hospitalization data:

# Run for latest data, save as RDS
indivHosp_20220907 <- downloadReadHospitalData(loc="./RInputFiles/Coronavirus/HHS_Hospital_20220907.csv")
## 
## File ./RInputFiles/Coronavirus/HHS_Hospital_20220907.csv already exists
## File will not be downloaded since ovrWrite is not TRUE
## Rows: 269456 Columns: 128
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr   (11): hospital_pk, state, ccn, hospital_name, address, city, zip, hosp...
## dbl  (114): total_beds_7_day_avg, all_adult_hospital_beds_7_day_avg, all_adu...
## lgl    (2): is_metro_micro, is_corrected
## date   (1): collection_week
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
## Rows: 269,456
## Columns: 128
## $ hospital_pk                                                                        <chr> …
## $ collection_week                                                                    <date> …
## $ state                                                                              <chr> …
## $ ccn                                                                                <chr> …
## $ hospital_name                                                                      <chr> …
## $ address                                                                            <chr> …
## $ city                                                                               <chr> …
## $ zip                                                                                <chr> …
## $ hospital_subtype                                                                   <chr> …
## $ fips_code                                                                          <chr> …
## $ is_metro_micro                                                                     <lgl> …
## $ total_beds_7_day_avg                                                               <dbl> …
## $ all_adult_hospital_beds_7_day_avg                                                  <dbl> …
## $ all_adult_hospital_inpatient_beds_7_day_avg                                        <dbl> …
## $ inpatient_beds_used_7_day_avg                                                      <dbl> …
## $ all_adult_hospital_inpatient_bed_occupied_7_day_avg                                <dbl> …
## $ inpatient_beds_used_covid_7_day_avg                                                <dbl> …
## $ total_adult_patients_hospitalized_confirmed_and_suspected_covid_7_day_avg          <dbl> …
## $ total_adult_patients_hospitalized_confirmed_covid_7_day_avg                        <dbl> …
## $ total_pediatric_patients_hospitalized_confirmed_and_suspected_covid_7_day_avg      <dbl> …
## $ total_pediatric_patients_hospitalized_confirmed_covid_7_day_avg                    <dbl> …
## $ inpatient_beds_7_day_avg                                                           <dbl> …
## $ total_icu_beds_7_day_avg                                                           <dbl> …
## $ total_staffed_adult_icu_beds_7_day_avg                                             <dbl> …
## $ icu_beds_used_7_day_avg                                                            <dbl> …
## $ staffed_adult_icu_bed_occupancy_7_day_avg                                          <dbl> …
## $ staffed_icu_adult_patients_confirmed_and_suspected_covid_7_day_avg                 <dbl> …
## $ staffed_icu_adult_patients_confirmed_covid_7_day_avg                               <dbl> …
## $ total_patients_hospitalized_confirmed_influenza_7_day_avg                          <dbl> …
## $ icu_patients_confirmed_influenza_7_day_avg                                         <dbl> …
## $ total_patients_hospitalized_confirmed_influenza_and_covid_7_day_avg                <dbl> …
## $ total_beds_7_day_sum                                                               <dbl> …
## $ all_adult_hospital_beds_7_day_sum                                                  <dbl> …
## $ all_adult_hospital_inpatient_beds_7_day_sum                                        <dbl> …
## $ inpatient_beds_used_7_day_sum                                                      <dbl> …
## $ all_adult_hospital_inpatient_bed_occupied_7_day_sum                                <dbl> …
## $ inpatient_beds_used_covid_7_day_sum                                                <dbl> …
## $ total_adult_patients_hospitalized_confirmed_and_suspected_covid_7_day_sum          <dbl> …
## $ total_adult_patients_hospitalized_confirmed_covid_7_day_sum                        <dbl> …
## $ total_pediatric_patients_hospitalized_confirmed_and_suspected_covid_7_day_sum      <dbl> …
## $ total_pediatric_patients_hospitalized_confirmed_covid_7_day_sum                    <dbl> …
## $ inpatient_beds_7_day_sum                                                           <dbl> …
## $ total_icu_beds_7_day_sum                                                           <dbl> …
## $ total_staffed_adult_icu_beds_7_day_sum                                             <dbl> …
## $ icu_beds_used_7_day_sum                                                            <dbl> …
## $ staffed_adult_icu_bed_occupancy_7_day_sum                                          <dbl> …
## $ staffed_icu_adult_patients_confirmed_and_suspected_covid_7_day_sum                 <dbl> …
## $ staffed_icu_adult_patients_confirmed_covid_7_day_sum                               <dbl> …
## $ total_patients_hospitalized_confirmed_influenza_7_day_sum                          <dbl> …
## $ icu_patients_confirmed_influenza_7_day_sum                                         <dbl> …
## $ total_patients_hospitalized_confirmed_influenza_and_covid_7_day_sum                <dbl> …
## $ total_beds_7_day_coverage                                                          <dbl> …
## $ all_adult_hospital_beds_7_day_coverage                                             <dbl> …
## $ all_adult_hospital_inpatient_beds_7_day_coverage                                   <dbl> …
## $ inpatient_beds_used_7_day_coverage                                                 <dbl> …
## $ all_adult_hospital_inpatient_bed_occupied_7_day_coverage                           <dbl> …
## $ inpatient_beds_used_covid_7_day_coverage                                           <dbl> …
## $ total_adult_patients_hospitalized_confirmed_and_suspected_covid_7_day_coverage     <dbl> …
## $ total_adult_patients_hospitalized_confirmed_covid_7_day_coverage                   <dbl> …
## $ total_pediatric_patients_hospitalized_confirmed_and_suspected_covid_7_day_coverage <dbl> …
## $ total_pediatric_patients_hospitalized_confirmed_covid_7_day_coverage               <dbl> …
## $ inpatient_beds_7_day_coverage                                                      <dbl> …
## $ total_icu_beds_7_day_coverage                                                      <dbl> …
## $ total_staffed_adult_icu_beds_7_day_coverage                                        <dbl> …
## $ icu_beds_used_7_day_coverage                                                       <dbl> …
## $ staffed_adult_icu_bed_occupancy_7_day_coverage                                     <dbl> …
## $ staffed_icu_adult_patients_confirmed_and_suspected_covid_7_day_coverage            <dbl> …
## $ staffed_icu_adult_patients_confirmed_covid_7_day_coverage                          <dbl> …
## $ total_patients_hospitalized_confirmed_influenza_7_day_coverage                     <dbl> …
## $ icu_patients_confirmed_influenza_7_day_coverage                                    <dbl> …
## $ total_patients_hospitalized_confirmed_influenza_and_covid_7_day_coverage           <dbl> …
## $ previous_day_admission_adult_covid_confirmed_7_day_sum                             <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_18-19_7_day_sum`                     <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_20-29_7_day_sum`                     <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_30-39_7_day_sum`                     <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_40-49_7_day_sum`                     <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_50-59_7_day_sum`                     <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_60-69_7_day_sum`                     <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_70-79_7_day_sum`                     <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_80+_7_day_sum`                       <dbl> …
## $ previous_day_admission_adult_covid_confirmed_unknown_7_day_sum                     <dbl> …
## $ previous_day_admission_pediatric_covid_confirmed_7_day_sum                         <dbl> …
## $ previous_day_covid_ED_visits_7_day_sum                                             <dbl> …
## $ previous_day_admission_adult_covid_suspected_7_day_sum                             <dbl> …
## $ `previous_day_admission_adult_covid_suspected_18-19_7_day_sum`                     <dbl> …
## $ `previous_day_admission_adult_covid_suspected_20-29_7_day_sum`                     <dbl> …
## $ `previous_day_admission_adult_covid_suspected_30-39_7_day_sum`                     <dbl> …
## $ `previous_day_admission_adult_covid_suspected_40-49_7_day_sum`                     <dbl> …
## $ `previous_day_admission_adult_covid_suspected_50-59_7_day_sum`                     <dbl> …
## $ `previous_day_admission_adult_covid_suspected_60-69_7_day_sum`                     <dbl> …
## $ `previous_day_admission_adult_covid_suspected_70-79_7_day_sum`                     <dbl> …
## $ `previous_day_admission_adult_covid_suspected_80+_7_day_sum`                       <dbl> …
## $ previous_day_admission_adult_covid_suspected_unknown_7_day_sum                     <dbl> …
## $ previous_day_admission_pediatric_covid_suspected_7_day_sum                         <dbl> …
## $ previous_day_total_ED_visits_7_day_sum                                             <dbl> …
## $ previous_day_admission_influenza_confirmed_7_day_sum                               <dbl> …
## $ geocoded_hospital_address                                                          <chr> …
## $ hhs_ids                                                                            <chr> …
## $ previous_day_admission_adult_covid_confirmed_7_day_coverage                        <dbl> …
## $ previous_day_admission_pediatric_covid_confirmed_7_day_coverage                    <dbl> …
## $ previous_day_admission_adult_covid_suspected_7_day_coverage                        <dbl> …
## $ previous_day_admission_pediatric_covid_suspected_7_day_coverage                    <dbl> …
## $ previous_week_personnel_covid_vaccinated_doses_administered_7_day                  <dbl> …
## $ total_personnel_covid_vaccinated_doses_none_7_day                                  <dbl> …
## $ total_personnel_covid_vaccinated_doses_one_7_day                                   <dbl> …
## $ total_personnel_covid_vaccinated_doses_all_7_day                                   <dbl> …
## $ previous_week_patients_covid_vaccinated_doses_one_7_day                            <dbl> …
## $ previous_week_patients_covid_vaccinated_doses_all_7_day                            <dbl> …
## $ is_corrected                                                                       <lgl> …
## $ all_pediatric_inpatient_bed_occupied_7_day_avg                                     <dbl> …
## $ all_pediatric_inpatient_bed_occupied_7_day_coverage                                <dbl> …
## $ all_pediatric_inpatient_bed_occupied_7_day_sum                                     <dbl> …
## $ all_pediatric_inpatient_beds_7_day_avg                                             <dbl> …
## $ all_pediatric_inpatient_beds_7_day_coverage                                        <dbl> …
## $ all_pediatric_inpatient_beds_7_day_sum                                             <dbl> …
## $ previous_day_admission_pediatric_covid_confirmed_0_4_7_day_sum                     <dbl> …
## $ previous_day_admission_pediatric_covid_confirmed_12_17_7_day_sum                   <dbl> …
## $ previous_day_admission_pediatric_covid_confirmed_5_11_7_day_sum                    <dbl> …
## $ previous_day_admission_pediatric_covid_confirmed_unknown_7_day_sum                 <dbl> …
## $ staffed_icu_pediatric_patients_confirmed_covid_7_day_avg                           <dbl> …
## $ staffed_icu_pediatric_patients_confirmed_covid_7_day_coverage                      <dbl> …
## $ staffed_icu_pediatric_patients_confirmed_covid_7_day_sum                           <dbl> …
## $ staffed_pediatric_icu_bed_occupancy_7_day_avg                                      <dbl> …
## $ staffed_pediatric_icu_bed_occupancy_7_day_coverage                                 <dbl> …
## $ staffed_pediatric_icu_bed_occupancy_7_day_sum                                      <dbl> …
## $ total_staffed_pediatric_icu_beds_7_day_avg                                         <dbl> …
## $ total_staffed_pediatric_icu_beds_7_day_coverage                                    <dbl> …
## $ total_staffed_pediatric_icu_beds_7_day_sum                                         <dbl> …
## 
## Hospital Subtype Counts:
## # A tibble: 4 × 2
##   hospital_subtype               n
##   <chr>                      <int>
## 1 Childrens Hospitals         5077
## 2 Critical Access Hospitals  72331
## 3 Long Term                  18519
## 4 Short Term                173529
## 
## Records other than 50 states and DC
## # A tibble: 5 × 2
##   state     n
##   <chr> <int>
## 1 AS       54
## 2 GU      106
## 3 MP       46
## 4 PR     2864
## 5 VI      106
## 
## Record types for key metrics
## # A tibble: 10 × 5
##    name                                              `NA` Posit…¹ Value…²  Total
##    <chr>                                            <int>   <int>   <int>  <int>
##  1 all_adult_hospital_beds_7_day_avg                64869  204079     508 269456
##  2 all_adult_hospital_inpatient_bed_occupied_7_day…   143  247227   22086 269456
##  3 icu_beds_used_7_day_avg                             64  237310   32082 269456
##  4 inpatient_beds_7_day_avg                            67  268366    1023 269456
##  5 inpatient_beds_used_7_day_avg                       51  248042   21363 269456
##  6 inpatient_beds_used_covid_7_day_avg                 32  182000   87424 269456
##  7 staffed_icu_adult_patients_confirmed_and_suspec…   162  184312   84982 269456
##  8 total_adult_patients_hospitalized_confirmed_and…   121  181944   87391 269456
##  9 total_beds_7_day_avg                             63149  206009     298 269456
## 10 total_icu_beds_7_day_avg                            74  255402   13980 269456
## # … with abbreviated variable names ¹​Positive, ²​`Value -999999`
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

saveToRDS(indivHosp_20220907, ovrWriteError=FALSE)
## 
## File already exists: ./RInputFiles/Coronavirus/indivHosp_20220907.RDS 
## 
## Not replacing the existing file since ovrWrite=FALSE
## NULL

Post-processing is run, including hospital summaries:

# Create pivoted burden data
burdenPivotList_220907 <- postProcessCDCDaily(cdc_daily_220907, 
                                              dataThruLabel="Aug 2022", 
                                              keyDatesBurden=c("2022-08-31", "2022-02-28", 
                                                               "2021-08-31", "2021-02-28"
                                                               ),
                                              keyDatesVaccine=c("2022-08-31", "2022-03-31", 
                                                                "2021-10-31", "2021-05-31"
                                                                ), 
                                              returnData=TRUE
                                              )
## Joining, by = "state"
## 
## *** File has been checked for uniqueness by: state date name
## Warning: Removed 24 row(s) containing missing values (geom_path).

## Warning: Removed 24 rows containing missing values (position_stack).

## Warning: Removed 24 rows containing missing values (position_stack).

## Warning: Removed 9 row(s) containing missing values (geom_path).

# Create hospitalized per capita data
hospPerCap_220907 <- hospAgePerCapita(readFromRDS("dfStateAgeBucket2019"), 
                                      lst=burdenPivotList_220907, 
                                      popVar="pop2019", 
                                      excludeState=c(), 
                                      cumStartDate="2020-07-15"
                                      )
## Warning: Removed 18 row(s) containing missing values (geom_path).

burdenPivotList_220907$hospAge %>%
    group_by(adultPed, confSusp, age, name) %>%
    summarize(value=sum(value, na.rm=TRUE), n=n(), .groups="drop")
## # A tibble: 18 × 6
##    adultPed confSusp  age   name                                     value     n
##    <chr>    <chr>     <chr> <chr>                                    <dbl> <int>
##  1 adult    confirmed 0-19  previous_day_admission_adult_covid_con… 4.70e4 49367
##  2 adult    confirmed 20-29 previous_day_admission_adult_covid_con… 2.86e5 49367
##  3 adult    confirmed 30-39 previous_day_admission_adult_covid_con… 4.12e5 49367
##  4 adult    confirmed 40-49 previous_day_admission_adult_covid_con… 4.96e5 49367
##  5 adult    confirmed 50-59 previous_day_admission_adult_covid_con… 7.91e5 49367
##  6 adult    confirmed 60-69 previous_day_admission_adult_covid_con… 1.04e6 49367
##  7 adult    confirmed 70-79 previous_day_admission_adult_covid_con… 1.04e6 49367
##  8 adult    confirmed 80+   previous_day_admission_adult_covid_con… 9.32e5 49367
##  9 adult    suspected 0-19  previous_day_admission_adult_covid_sus… 3.83e4 49367
## 10 adult    suspected 20-29 previous_day_admission_adult_covid_sus… 2.56e5 49367
## 11 adult    suspected 30-39 previous_day_admission_adult_covid_sus… 3.35e5 49367
## 12 adult    suspected 40-49 previous_day_admission_adult_covid_sus… 3.39e5 49367
## 13 adult    suspected 50-59 previous_day_admission_adult_covid_sus… 5.37e5 49367
## 14 adult    suspected 60-69 previous_day_admission_adult_covid_sus… 7.38e5 49367
## 15 adult    suspected 70-79 previous_day_admission_adult_covid_sus… 7.19e5 49367
## 16 adult    suspected 80+   previous_day_admission_adult_covid_sus… 6.55e5 49367
## 17 ped      confirmed 0-19  previous_day_admission_pediatric_covid… 1.67e5 49367
## 18 ped      suspected 0-19  previous_day_admission_pediatric_covid… 3.74e5 49367
saveToRDS(burdenPivotList_220907, ovrWriteError=FALSE)
saveToRDS(hospPerCap_220907, ovrWriteError=FALSE)

Peaks and valleys of key metrics are also updated:

peakValleyCDCDaily(cdc_daily_220907)
## Warning: Removed 6 row(s) containing missing values (geom_path).

## Warning: Removed 6 row(s) containing missing values (geom_path).

## Warning: Removed 6 row(s) containing missing values (geom_path).

## Warning: Removed 20 row(s) containing missing values (geom_path).

## Warning: Removed 20 row(s) containing missing values (geom_path).

## # A tibble: 7,740 × 8
##    date       state   vxa   vxc vxa_isPeak vxc_isPeak vxa_isValley vxc_isValley
##    <date>     <chr> <dbl> <dbl> <lgl>      <lgl>      <lgl>        <lgl>       
##  1 2020-12-01 CA       NA    NA FALSE      FALSE      FALSE        FALSE       
##  2 2020-12-01 FL       NA    NA FALSE      FALSE      FALSE        FALSE       
##  3 2020-12-01 GA       NA    NA FALSE      FALSE      FALSE        FALSE       
##  4 2020-12-01 IL       NA    NA FALSE      FALSE      FALSE        FALSE       
##  5 2020-12-01 MI       NA    NA FALSE      FALSE      FALSE        FALSE       
##  6 2020-12-01 NC       NA    NA FALSE      FALSE      FALSE        FALSE       
##  7 2020-12-01 NJ       NA    NA FALSE      FALSE      FALSE        FALSE       
##  8 2020-12-01 NY       NA    NA FALSE      FALSE      FALSE        FALSE       
##  9 2020-12-01 OH       NA    NA FALSE      FALSE      FALSE        FALSE       
## 10 2020-12-01 PA       NA    NA FALSE      FALSE      FALSE        FALSE       
## # … with 7,730 more rows
## # ℹ Use `print(n = ...)` to see more rows

Hospital capacity is updated using a mix of old data (for 2021) and new data:

identical(names(indivHosp_20220907), names(readFromRDS("indivHosp_20220704")))
## [1] TRUE
modHospData <- bind_rows(filter(readFromRDS("indivHosp_20220704"), lubridate::year(collection_week)<2022), 
                         filter(indivHosp_20220907, lubridate::year(collection_week)>=2022), 
                         .id="src"
                         )
updated_modStateHosp_20220907 <- hospitalCapacityCDCDaily(modHospData, 
                                                          plotSub="Aug 2020 to Aug 2022\nOld data used pre-2022"
                                                          )

Data availability by source and time is assessed:

# Temporary function to aggregate data
tempCounter <- function(df) {
    df %>%
        select(hospital_pk, collection_week, all_of(names(hhsMapper))) %>%
        colRenamer(vecRename=hhsMapper) %>%
        pivot_longer(-c(hospital_pk, collection_week)) %>%
        filter(!is.na(value), value>0) %>%
        count(collection_week, name)
}

dfTemp <- bind_rows(tempCounter(indivHosp_20220907), tempCounter(readFromRDS("indivHosp_20220704")), .id="src")

dfTemp %>%
    select(collection_week, name) %>%
    unique() %>%
    bind_rows(., ., .id="src")  %>%
    full_join(dfTemp, by=c("src", "collection_week", "name")) %>%
    mutate(src=c("1"="SEP-2022", "2"="JUL-2022")[src]) %>%
    mutate(n=ifelse(is.na(n), 0, n)) %>%
    ggplot(aes(x=collection_week, y=n)) +
    geom_line(aes(group=src, color=src)) + 
    facet_wrap(~name) + 
    labs(title="Number of hospitals in US reporting >0 on metric by week", x=NULL, y="# Hospitals Reporting > 0") + 
    scale_color_discrete("Data Source:")

dfTemp %>%
    select(collection_week, name) %>%
    unique() %>%
    bind_rows(., ., .id="src")  %>%
    full_join(dfTemp, by=c("src", "collection_week", "name")) %>%
    mutate(src=c("1"="SEP-2022", "2"="JUL-2022")[src]) %>%
    mutate(n=ifelse(is.na(n), 0, n)) %>% 
    group_by(collection_week, name) %>% 
    summarize(delta=sum(ifelse(src=="SEP-2022", n, 0)-ifelse(src!="SEP-2022", n, 0)), .groups="drop") %>%
    ggplot(aes(x=collection_week, y=delta)) +
    geom_line(aes(color=case_when(delta>=0 ~ "darkgreen", TRUE ~ "red"))) +
    geom_hline(yintercept=0, lty=2) +
    geom_vline(xintercept=c(as.Date("2021-08-20"), as.Date("2022-06-24")), lty=2) +
    scale_color_identity(NULL) +
    facet_wrap(~name) + 
    labs(title="Delta in Number of hospitals in US reporting >0 on metric by week", 
         subtitle="Trend break dashed lines at 2021-08-20 and 2022-06-24",
         x=NULL, 
         y="Delta in # Hospitals Reporting > 0"
         )

The process is converted to functional form:

multiSourceDataCombine <- function(lst, timeVec, keyVar="collection_week", idName="src") {
    
    # FUNCTION ARGUMENTS:
    # lst: list of data frames to be combined
    # timeVec: vector of time cut points (data before timeVec[1] taken from lst[[1]], etc.)
    # keyVar: variable describing time in the data
    # idName: name of column for .id when files combined
    
    # Check list lengths
    if(length(lst)==0) {
        cat("\nEmpty list passed, returning 0x0 tibble\n")
        return(tibble::tibble())
    } else if (length(lst)==1) {
        cat("\nList of length 1 passed, returning item in list as-is")
        return(lst[[1]])
    }
    
    # Check that timeVec matches
    if(length(lst) != length(timeVec) + 1) stop("\nMismatch of lst and timeVec\n")
    
    # Check that all data frames have the same column names in the same order
    vecNames <- names(lst[[1]])
    for(n in 2:length(lst)) if(!isTRUE(identical(names(lst[[n]]), vecNames))) stop("\nName mismatch in files\n")
    
    # Combine data
    bind_rows(lst, .id=idName) %>%
        mutate(srcNum=as.integer(get(idName)), 
               dateMin=ifelse(srcNum==1, NA, timeVec[srcNum-1]), 
               dateMax=ifelse(srcNum==max(srcNum), NA, timeVec[srcNum])
               ) %>%
        filter(is.na(dateMin) | get(keyVar) >= dateMin, 
               is.na(dateMax) | get(keyVar) < dateMax
               ) %>%
        select(-srcNum, -dateMin, -dateMax)
    
}

# Create modified hospital data
multiSourceHosp_20220902 <- multiSourceDataCombine(list(readFromRDS("indivHosp_20220704"), 
                                                        indivHosp_20220907
                                                        ), 
                                                   timeVec=as.Date("2022-01-01")
                                                   )

# Confirm that function produces expected output
multiSourceHosp_20220902 %>%
    select(-src) %>%
    identical(modHospData %>% select(-src))
## [1] TRUE

The updated hospital data are then plotted:

# Run hospital plots
modStateHosp_20220902 <- hospitalCapacityCDCDaily(multiSourceHosp_20220902, 
                                                  plotSub="Aug 2020 to Aug 2022\nOld data used pre-2022"
                                                  )

Data Refreshes

Data From 2022-10-02

The latest CDC case, hospitalization, and death data are downloaded and processed:

readList <- list("cdcDaily"="./RInputFiles/Coronavirus/CDC_dc_downloaded_221002.csv", 
                 "cdcHosp"="./RInputFiles/Coronavirus/CDC_h_downloaded_221002.csv", 
                 "vax"="./RInputFiles/Coronavirus/vaxData_downloaded_221002.csv"
                 )
compareList <- list("cdcDaily"=readFromRDS("cdc_daily_220907")$dfRaw$cdcDaily, 
                    "cdcHosp"=readFromRDS("cdc_daily_220907")$dfRaw$cdcHosp, 
                    "vax"=readFromRDS("cdc_daily_220907")$dfRaw$vax
                    )

cdc_daily_221002 <- readRunCDCDaily(thruLabel="Sep 30, 2022", 
                                    downloadTo=lapply(readList, FUN=function(x) if(file.exists(x)) NA else x), 
                                    readFrom=readList,
                                    compareFile=compareList, 
                                    writeLog=NULL, 
                                    useClusters=readFromRDS("cdc_daily_210528")$useClusters, 
                                    weightedMeanAggs=c("tcpm7", "tdpm7", "cpm7", "dpm7", "hpm7", 
                                                       "vxcpm7", "vxcgte65pct"
                                                       ),
                                    skipAssessmentPlots=FALSE, 
                                    brewPalette="Paired"
                                    )
## Rows: 58980 Columns: 15
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr  (5): submission_date, state, created_at, consent_cases, consent_deaths
## dbl (10): tot_cases, conf_cases, prob_cases, new_case, pnew_case, tot_death,...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
## 
## *** File has been checked for uniqueness by: state date

## 
## 
## Checking for similarity of: column names
## In reference but not in current: 
## In current but not in reference: 
## 
## Checking for similarity of: date
## In reference but not in current: 0
## In current but not in reference: 25
## 
## Checking for similarity of: state
## In reference but not in current: 
## In current but not in reference:

## 
## 
## ***Differences of at least 5 and at least 5%
## 
##          date       name newValue refValue absDelta   pctDelta
## 1  2022-09-04 new_deaths      109       20       89 1.37984496
## 2  2022-09-03 new_deaths      116       24       92 1.31428571
## 3  2022-08-27 new_deaths      163       91       72 0.56692913
## 4  2022-09-05 new_deaths      106       60       46 0.55421687
## 5  2022-08-28 new_deaths      117       87       30 0.29411765
## 6  2022-08-20 new_deaths      139      111       28 0.22400000
## 7  2021-03-03 new_deaths     1899     1547      352 0.20429483
## 8  2022-08-06 new_deaths      174      142       32 0.20253165
## 9  2022-08-13 new_deaths      137      112       25 0.20080321
## 10 2020-09-14 new_deaths      376      453       77 0.18576598
## 11 2021-03-02 new_deaths     1134     1357      223 0.17904456
## 12 2022-08-21 new_deaths      122      102       20 0.17857143
## 13 2022-07-02 new_deaths      146      124       22 0.16296296
## 14 2022-09-01 new_deaths      499      428       71 0.15318231
## 15 2022-07-30 new_deaths      151      130       21 0.14946619
## 16 2022-07-04 new_deaths      120      138       18 0.13953488
## 17 2021-03-18 new_deaths      961      843      118 0.13082040
## 18 2022-06-27 new_deaths      259      295       36 0.12996390
## 19 2022-09-02 new_deaths      509      453       56 0.11642412
## 20 2022-08-14 new_deaths      115      103       12 0.11009174
## 21 2022-05-30 new_deaths       78       86        8 0.09756098
## 22 2022-04-25 new_deaths      181      199       18 0.09473684
## 23 2021-03-19 new_deaths     1080     1182      102 0.09018568
## 24 2022-07-09 new_deaths      120      110       10 0.08695652
## 25 2022-08-25 new_deaths      536      492       44 0.08560311
## 26 2022-08-30 new_deaths      633      582       51 0.08395062
## 27 2022-04-04 new_deaths      325      353       28 0.08259587
## 28 2022-08-26 new_deaths      674      621       53 0.08185328
## 29 2022-07-16 new_deaths      163      151       12 0.07643312
## 30 2022-08-01 new_deaths      402      433       31 0.07425150
## 31 2021-10-11 new_deaths      983      915       68 0.07165437
## 32 2022-06-20 new_deaths      140      150       10 0.06896552
## 33 2021-12-28 new_deaths     2334     2185      149 0.06594379
## 34 2022-08-31 new_deaths      778      830       52 0.06467662
## 35 2020-09-15 new_deaths      827      777       50 0.06234414
## 36 2020-09-21 new_deaths      547      580       33 0.05856256
## 37 2021-02-28 new_deaths     1027     1088       61 0.05768322
## 38 2022-08-19 new_deaths      622      588       34 0.05619835
## 39 2021-03-01 new_deaths     1333     1262       71 0.05472062
## 40 2021-06-28 new_deaths      183      193       10 0.05319149
## 41 2021-10-04 new_deaths     1298     1234       64 0.05055292
## 42 2022-09-03  new_cases    26751    14942    11809 0.56647399
## 43 2022-09-04  new_cases    26642    18143     8499 0.37954672
## 44 2022-08-27  new_cases    31520    27723     3797 0.12818392
## 45 2022-08-20  new_cases    31149    27757     3392 0.11516654
## 46 2022-07-04  new_cases    46367    50779     4412 0.09083236
## 47 2022-08-06  new_cases    36583    33586     2997 0.08542234
## 48 2022-08-28  new_cases    29299    26941     2358 0.08385491
## 49 2022-08-13  new_cases    33397    30736     2661 0.08298380
## 50 2022-07-30  new_cases    41625    38338     3287 0.08221302
## 51 2022-08-29  new_cases    80569    87383     6814 0.08114223
## 52 2022-08-14  new_cases    25021    23110     1911 0.07940828
## 53 2022-08-21  new_cases    30913    28587     2326 0.07818487
## 54 2022-07-11  new_cases   115394   124421     9027 0.07528303
## 55 2022-09-01  new_cases   106616    99807     6809 0.06597133
## 56 2021-10-04  new_cases    92025    86161     5864 0.06581886
## 57 2021-09-20  new_cases    98599    92534     6065 0.06346366
## 58 2022-07-09  new_cases    58075    54584     3491 0.06197463
## 59 2022-07-23  new_cases    56226    52972     3254 0.05959816
## 60 2022-09-02  new_cases   107474   101329     6145 0.05885931
## 61 2022-07-02  new_cases    51723    48818     2905 0.05778737
## 62 2022-08-07  new_cases    37208    35135     2073 0.05731031
## 63 2021-09-06  new_cases   115878   109526     6352 0.05636102
## 64 2022-07-18  new_cases   103308   109131     5823 0.05482044
## 65 2021-09-13  new_cases   119108   112822     6286 0.05420601
## 66 2022-07-31  new_cases    42016    39803     2213 0.05409501
## 67 2021-09-27  new_cases   107419   101840     5579 0.05332148
## 68 2022-07-16  new_cases    58177    55197     2980 0.05256937

## 
## 
## ***Differences of at least 0 and at least 0.1%
## 
##    state       name  newValue  refValue absDelta    pctDelta
## 1     VA tot_deaths   9582222   9605584    23362 0.002435088
## 2     KY tot_deaths   7519333   7506070    13263 0.001765410
## 3     VA  tot_cases 726116885 728276276  2159391 0.002969474
## 4     KY new_deaths     16974     16757      217 0.012866503
## 5     AL new_deaths     20360     20203      157 0.007741045
## 6     VA new_deaths     21479     21334      145 0.006773644
## 7     FL new_deaths     80737     80209      528 0.006561207
## 8     KS new_deaths      9001      9054       53 0.005870950
## 9     NC new_deaths     26416     26338       78 0.002957122
## 10    OK new_deaths     13708     13746       38 0.002768267
## 11    SC new_deaths     18313     18263       50 0.002734033
## 12    SC  new_cases   1688432   1674281    14151 0.008416419
## 13    KY  new_cases   1559169   1546719    12450 0.008017031
## 14    NC  new_cases   3143278   3123308    19970 0.006373486
## 15    CO  new_cases   1637839   1634396     3443 0.002104372
## 16    WA  new_cases   1789708   1787212     2496 0.001395614
## 
## 
## 
## Raw file for cdcDaily:
## Rows: 58,980
## Columns: 15
## $ date           <date> 2021-03-11, 2021-12-01, 2020-04-07, 2020-04-08, 2020-0…
## $ state          <chr> "KS", "ND", "AS", "AR", "AR", "ND", "IN", "AR", "NY", "…
## $ tot_cases      <dbl> 297229, 163565, 0, 1071, 0, 118491, 668765, 56199, 1882…
## $ conf_cases     <dbl> 241035, 135705, NA, NA, NA, 107475, NA, NA, NA, 144788,…
## $ prob_cases     <dbl> 56194, 27860, NA, NA, NA, 11016, NA, NA, NA, 29179, 125…
## $ new_cases      <dbl> 0, 589, 0, 78, 0, 536, 487, 547, 318, 667, 154, 1509, 0…
## $ pnew_case      <dbl> 0, 220, NA, NA, NA, 66, 0, 0, 0, 274, 43, 0, 0, 616, 0,…
## $ tot_deaths     <dbl> 4851, 1907, 0, 18, 0, 1562, 12710, 674, 8822, 2911, 115…
## $ conf_death     <dbl> NA, NA, NA, NA, NA, NA, 12315, NA, NA, 2482, 9205, NA, …
## $ prob_death     <dbl> NA, NA, NA, NA, NA, NA, 395, NA, NA, 429, 2325, NA, 152…
## $ new_deaths     <dbl> 0, 9, 0, 0, 0, 1, 7, 11, 2, 8, 5, 6, 0, 100, 0, 5, 0, 0…
## $ pnew_death     <dbl> 0, 0, NA, NA, NA, 0, 2, 0, 0, 3, 1, 0, 0, 34, 0, 0, 0, …
## $ created_at     <chr> "03/12/2021 03:20:13 PM", "12/02/2021 02:35:20 PM", "04…
## $ consent_cases  <chr> "Agree", "Agree", NA, "Not agree", "Not agree", "Agree"…
## $ consent_deaths <chr> "N/A", "Not agree", NA, "Not agree", "Not agree", "Not …
## Rows: 50717 Columns: 135
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr    (1): state
## dbl  (132): critical_staffing_shortage_today_yes, critical_staffing_shortage...
## lgl    (1): geocoded_state
## date   (1): date
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.

## 
## *** File has been checked for uniqueness by: state date

## 
## 
## Checking for similarity of: column names
## In reference but not in current: 
## In current but not in reference: 
## 
## Checking for similarity of: date
## In reference but not in current: 0
## In current but not in reference: 25
## 
## Checking for similarity of: state
## In reference but not in current: 
## In current but not in reference:

## 
## 
## ***Differences of at least 5 and at least 5%
## 
##         date       name newValue refValue absDelta  pctDelta
## 1 2022-09-06        inp    35899    31213     4686 0.1396472
## 2 2020-07-25   hosp_ped     4543     3964      579 0.1361232
## 3 2022-09-06   hosp_ped     1651     1543      108 0.0676268
## 4 2022-09-06 hosp_adult    34457    29670     4787 0.1492975

## 
## 
## ***Differences of at least 0 and at least 0.1%
## 
##    state       name newValue refValue absDelta    pctDelta
## 1     KY        inp   816280   813897     2383 0.002923609
## 2     NC        inp  1500803  1499030     1773 0.001182066
## 3     ME   hosp_ped     2525     2573       48 0.018830914
## 4     SC   hosp_ped     9677     9528      149 0.015516793
## 5     WV   hosp_ped     6031     6124       93 0.015302345
## 6     DE   hosp_ped     5656     5585       71 0.012632328
## 7     KY   hosp_ped    21854    21680      174 0.007993752
## 8     MS   hosp_ped    12564    12470       94 0.007509787
## 9     NJ   hosp_ped    20426    20300      126 0.006187693
## 10    MA   hosp_ped    13350    13270       80 0.006010518
## 11    MD   hosp_ped    18441    18334      107 0.005819171
## 12    UT   hosp_ped    10918    10980       62 0.005662618
## 13    VA   hosp_ped    19166    19260       94 0.004892521
## 14    NM   hosp_ped     8390     8351       39 0.004659220
## 15    ID   hosp_ped     4294     4275       19 0.004434590
## 16    CO   hosp_ped    22949    23039       90 0.003914065
## 17    KS   hosp_ped     5109     5128       19 0.003712025
## 18    NV   hosp_ped     5680     5661       19 0.003350675
## 19    AR   hosp_ped    13462    13506       44 0.003263127
## 20    TN   hosp_ped    23438    23376       62 0.002648780
## 21    PA   hosp_ped    57278    57151      127 0.002219717
## 22    RI   hosp_ped     3719     3727        8 0.002148805
## 23    MT   hosp_ped     3511     3518        7 0.001991748
## 24    IL   hosp_ped    46107    46022       85 0.001845239
## 25    PR   hosp_ped    24430    24470       40 0.001635992
## 26    MO   hosp_ped    41624    41556       68 0.001635008
## 27    SD   hosp_ped     4436     4443        7 0.001576754
## 28    NC   hosp_ped    31811    31761       50 0.001573020
## 29    AL   hosp_ped    21961    21929       32 0.001458191
## 30    GA   hosp_ped    55159    55238       79 0.001431198
## 31    AK   hosp_ped     2922     2926        4 0.001367989
## 32    KY hosp_adult   743511   741160     2351 0.003167032
## 33    NC hosp_adult  1376148  1374437     1711 0.001244099
## 34    VT hosp_adult    25440    25466       26 0.001021491
## 
## 
## 
## Raw file for cdcHosp:
## Rows: 50,717
## Columns: 135
## $ state                                                                        <chr> …
## $ date                                                                         <date> …
## $ critical_staffing_shortage_today_yes                                         <dbl> …
## $ critical_staffing_shortage_today_no                                          <dbl> …
## $ critical_staffing_shortage_today_not_reported                                <dbl> …
## $ critical_staffing_shortage_anticipated_within_week_yes                       <dbl> …
## $ critical_staffing_shortage_anticipated_within_week_no                        <dbl> …
## $ critical_staffing_shortage_anticipated_within_week_not_reported              <dbl> …
## $ hospital_onset_covid                                                         <dbl> …
## $ hospital_onset_covid_coverage                                                <dbl> …
## $ inpatient_beds                                                               <dbl> …
## $ inpatient_beds_coverage                                                      <dbl> …
## $ inpatient_beds_used                                                          <dbl> …
## $ inpatient_beds_used_coverage                                                 <dbl> …
## $ inp                                                                          <dbl> …
## $ inpatient_beds_used_covid_coverage                                           <dbl> …
## $ previous_day_admission_adult_covid_confirmed                                 <dbl> …
## $ previous_day_admission_adult_covid_confirmed_coverage                        <dbl> …
## $ previous_day_admission_adult_covid_suspected                                 <dbl> …
## $ previous_day_admission_adult_covid_suspected_coverage                        <dbl> …
## $ previous_day_admission_pediatric_covid_confirmed                             <dbl> …
## $ previous_day_admission_pediatric_covid_confirmed_coverage                    <dbl> …
## $ previous_day_admission_pediatric_covid_suspected                             <dbl> …
## $ previous_day_admission_pediatric_covid_suspected_coverage                    <dbl> …
## $ staffed_adult_icu_bed_occupancy                                              <dbl> …
## $ staffed_adult_icu_bed_occupancy_coverage                                     <dbl> …
## $ staffed_icu_adult_patients_confirmed_and_suspected_covid                     <dbl> …
## $ staffed_icu_adult_patients_confirmed_and_suspected_covid_coverage            <dbl> …
## $ staffed_icu_adult_patients_confirmed_covid                                   <dbl> …
## $ staffed_icu_adult_patients_confirmed_covid_coverage                          <dbl> …
## $ hosp_adult                                                                   <dbl> …
## $ total_adult_patients_hospitalized_confirmed_and_suspected_covid_coverage     <dbl> …
## $ total_adult_patients_hospitalized_confirmed_covid                            <dbl> …
## $ total_adult_patients_hospitalized_confirmed_covid_coverage                   <dbl> …
## $ hosp_ped                                                                     <dbl> …
## $ total_pediatric_patients_hospitalized_confirmed_and_suspected_covid_coverage <dbl> …
## $ total_pediatric_patients_hospitalized_confirmed_covid                        <dbl> …
## $ total_pediatric_patients_hospitalized_confirmed_covid_coverage               <dbl> …
## $ total_staffed_adult_icu_beds                                                 <dbl> …
## $ total_staffed_adult_icu_beds_coverage                                        <dbl> …
## $ inpatient_beds_utilization                                                   <dbl> …
## $ inpatient_beds_utilization_coverage                                          <dbl> …
## $ inpatient_beds_utilization_numerator                                         <dbl> …
## $ inpatient_beds_utilization_denominator                                       <dbl> …
## $ percent_of_inpatients_with_covid                                             <dbl> …
## $ percent_of_inpatients_with_covid_coverage                                    <dbl> …
## $ percent_of_inpatients_with_covid_numerator                                   <dbl> …
## $ percent_of_inpatients_with_covid_denominator                                 <dbl> …
## $ inpatient_bed_covid_utilization                                              <dbl> …
## $ inpatient_bed_covid_utilization_coverage                                     <dbl> …
## $ inpatient_bed_covid_utilization_numerator                                    <dbl> …
## $ inpatient_bed_covid_utilization_denominator                                  <dbl> …
## $ adult_icu_bed_covid_utilization                                              <dbl> …
## $ adult_icu_bed_covid_utilization_coverage                                     <dbl> …
## $ adult_icu_bed_covid_utilization_numerator                                    <dbl> …
## $ adult_icu_bed_covid_utilization_denominator                                  <dbl> …
## $ adult_icu_bed_utilization                                                    <dbl> …
## $ adult_icu_bed_utilization_coverage                                           <dbl> …
## $ adult_icu_bed_utilization_numerator                                          <dbl> …
## $ adult_icu_bed_utilization_denominator                                        <dbl> …
## $ geocoded_state                                                               <lgl> …
## $ `previous_day_admission_adult_covid_confirmed_18-19`                         <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_18-19_coverage`                <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_20-29`                         <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_20-29_coverage`                <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_30-39`                         <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_30-39_coverage`                <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_40-49`                         <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_40-49_coverage`                <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_50-59`                         <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_50-59_coverage`                <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_60-69`                         <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_60-69_coverage`                <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_70-79`                         <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_70-79_coverage`                <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_80+`                           <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_80+_coverage`                  <dbl> …
## $ previous_day_admission_adult_covid_confirmed_unknown                         <dbl> …
## $ previous_day_admission_adult_covid_confirmed_unknown_coverage                <dbl> …
## $ `previous_day_admission_adult_covid_suspected_18-19`                         <dbl> …
## $ `previous_day_admission_adult_covid_suspected_18-19_coverage`                <dbl> …
## $ `previous_day_admission_adult_covid_suspected_20-29`                         <dbl> …
## $ `previous_day_admission_adult_covid_suspected_20-29_coverage`                <dbl> …
## $ `previous_day_admission_adult_covid_suspected_30-39`                         <dbl> …
## $ `previous_day_admission_adult_covid_suspected_30-39_coverage`                <dbl> …
## $ `previous_day_admission_adult_covid_suspected_40-49`                         <dbl> …
## $ `previous_day_admission_adult_covid_suspected_40-49_coverage`                <dbl> …
## $ `previous_day_admission_adult_covid_suspected_50-59`                         <dbl> …
## $ `previous_day_admission_adult_covid_suspected_50-59_coverage`                <dbl> …
## $ `previous_day_admission_adult_covid_suspected_60-69`                         <dbl> …
## $ `previous_day_admission_adult_covid_suspected_60-69_coverage`                <dbl> …
## $ `previous_day_admission_adult_covid_suspected_70-79`                         <dbl> …
## $ `previous_day_admission_adult_covid_suspected_70-79_coverage`                <dbl> …
## $ `previous_day_admission_adult_covid_suspected_80+`                           <dbl> …
## $ `previous_day_admission_adult_covid_suspected_80+_coverage`                  <dbl> …
## $ previous_day_admission_adult_covid_suspected_unknown                         <dbl> …
## $ previous_day_admission_adult_covid_suspected_unknown_coverage                <dbl> …
## $ deaths_covid                                                                 <dbl> …
## $ deaths_covid_coverage                                                        <dbl> …
## $ on_hand_supply_therapeutic_a_casirivimab_imdevimab_courses                   <dbl> …
## $ on_hand_supply_therapeutic_b_bamlanivimab_courses                            <dbl> …
## $ on_hand_supply_therapeutic_c_bamlanivimab_etesevimab_courses                 <dbl> …
## $ previous_week_therapeutic_a_casirivimab_imdevimab_courses_used               <dbl> …
## $ previous_week_therapeutic_b_bamlanivimab_courses_used                        <dbl> …
## $ previous_week_therapeutic_c_bamlanivimab_etesevimab_courses_used             <dbl> …
## $ icu_patients_confirmed_influenza                                             <dbl> …
## $ icu_patients_confirmed_influenza_coverage                                    <dbl> …
## $ previous_day_admission_influenza_confirmed                                   <dbl> …
## $ previous_day_admission_influenza_confirmed_coverage                          <dbl> …
## $ previous_day_deaths_covid_and_influenza                                      <dbl> …
## $ previous_day_deaths_covid_and_influenza_coverage                             <dbl> …
## $ previous_day_deaths_influenza                                                <dbl> …
## $ previous_day_deaths_influenza_coverage                                       <dbl> …
## $ total_patients_hospitalized_confirmed_influenza                              <dbl> …
## $ total_patients_hospitalized_confirmed_influenza_and_covid                    <dbl> …
## $ total_patients_hospitalized_confirmed_influenza_and_covid_coverage           <dbl> …
## $ total_patients_hospitalized_confirmed_influenza_coverage                     <dbl> …
## $ all_pediatric_inpatient_bed_occupied                                         <dbl> …
## $ all_pediatric_inpatient_bed_occupied_coverage                                <dbl> …
## $ all_pediatric_inpatient_beds                                                 <dbl> …
## $ all_pediatric_inpatient_beds_coverage                                        <dbl> …
## $ previous_day_admission_pediatric_covid_confirmed_0_4                         <dbl> …
## $ previous_day_admission_pediatric_covid_confirmed_0_4_coverage                <dbl> …
## $ previous_day_admission_pediatric_covid_confirmed_12_17                       <dbl> …
## $ previous_day_admission_pediatric_covid_confirmed_12_17_coverage              <dbl> …
## $ previous_day_admission_pediatric_covid_confirmed_5_11                        <dbl> …
## $ previous_day_admission_pediatric_covid_confirmed_5_11_coverage               <dbl> …
## $ previous_day_admission_pediatric_covid_confirmed_unknown                     <dbl> …
## $ previous_day_admission_pediatric_covid_confirmed_unknown_coverage            <dbl> …
## $ staffed_icu_pediatric_patients_confirmed_covid                               <dbl> …
## $ staffed_icu_pediatric_patients_confirmed_covid_coverage                      <dbl> …
## $ staffed_pediatric_icu_bed_occupancy                                          <dbl> …
## $ staffed_pediatric_icu_bed_occupancy_coverage                                 <dbl> …
## $ total_staffed_pediatric_icu_beds                                             <dbl> …
## $ total_staffed_pediatric_icu_beds_coverage                                    <dbl> …
## Warning: One or more parsing issues, see `problems()` for details
## Rows: 36440 Columns: 101
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr  (2): Date, Location
## dbl (93): MMWR_week, Distributed, Distributed_Janssen, Distributed_Moderna, ...
## lgl  (6): Second_Booster, Administered_Bivalent, Admin_Bivalent_PFR, Admin_B...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.

## 
## *** File has been checked for uniqueness by: state date

## 
## 
## Checking for similarity of: column names
## In reference but not in current: 
## In current but not in reference: Administered_Bivalent Admin_Bivalent_PFR Admin_Bivalent_MOD Dist_Bivalent_PFR Dist_Bivalent_MOD
## 
## Checking for similarity of: date
## In reference but not in current: 0
## In current but not in reference: 4
## 
## Checking for similarity of: state
## In reference but not in current: 
## In current but not in reference:

## 
## 
## ***Differences of at least 1 and at least 1%
## 
## [1] date     name     newValue refValue absDelta pctDelta
## <0 rows> (or 0-length row.names)
## 
## 
## ***Differences of at least 0 and at least 0.1%
## 
## [1] state    name     newValue refValue absDelta pctDelta
## <0 rows> (or 0-length row.names)
## 
## 
## 
## Raw file for vax:
## Rows: 36,440
## Columns: 101
## $ date                                   <date> 2022-09-28, 2022-09-28, 2022-0…
## $ MMWR_week                              <dbl> 39, 39, 39, 39, 39, 39, 39, 39,…
## $ state                                  <chr> "VA2", "NE", "DE", "WV", "IA", …
## $ Distributed                            <dbl> 8845320, 4747440, 2836355, 4821…
## $ Distributed_Janssen                    <dbl> 626900, 151900, 101200, 170200,…
## $ Distributed_Moderna                    <dbl> 4313180, 1627380, 1078600, 1924…
## $ Distributed_Pfizer                     <dbl> 3898140, 2963760, 1653155, 2719…
## $ Distributed_Novavax                    <dbl> 7100, 4400, 3400, 7000, 12500, …
## $ Distributed_Unk_Manuf                  <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0…
## $ Dist_Per_100K                          <dbl> 0, 245421, 291277, 269043, 2530…
## $ Distributed_Per_100k_5Plus             <dbl> 0, 263231, 308620, 283773, 2698…
## $ Distributed_Per_100k_12Plus            <dbl> 0, 293521, 337739, 309509, 2983…
## $ Distributed_Per_100k_18Plus            <dbl> 0, 325539, 368266, 336571, 3288…
## $ Distributed_Per_100k_65Plus            <dbl> 0, 1519390, 1501460, 1313760, 1…
## $ vxa                                    <dbl> 7846098, 3451226, 1970701, 2901…
## $ Administered_5Plus                     <dbl> 7845919, 3437511, 1963888, 2896…
## $ Administered_12Plus                    <dbl> 7845897, 3306108, 1902046, 2841…
## $ Administered_18Plus                    <dbl> 7842493, 3086344, 1785352, 2709…
## $ Administered_65Plus                    <dbl> 4223864, 970237, 620955, 983314…
## $ Administered_Janssen                   <dbl> 256285, 95847, 62987, 68294, 18…
## $ Administered_Moderna                   <dbl> 4052239, 1227878, 756774, 12486…
## $ Administered_Pfizer                    <dbl> 3537422, 2118721, 1148333, 1582…
## $ Administered_Novavax                   <dbl> 111, 194, 88, 95, 271, 193, 206…
## $ Administered_Unk_Manuf                 <dbl> 41, 8586, 2519, 2161, 1283, 462…
## $ Admin_Per_100k                         <dbl> 0, 178413, 202380, 161918, 1748…
## $ Admin_Per_100k_5Plus                   <dbl> 0, 190599, 213688, 170493, 1856…
## $ Admin_Per_100k_12Plus                  <dbl> 0, 204408, 226486, 182420, 1987…
## $ Admin_Per_100k_18Plus                  <dbl> 0, 211635, 231806, 189157, 2064…
## $ Admin_Per_100k_65Plus                  <dbl> 0, 310518, 328711, 267925, 3140…
## $ Recip_Administered                     <dbl> 7846098, 3471776, 1946433, 2908…
## $ Administered_Dose1_Recip               <dbl> 3545905, 1393418, 835939, 11911…
## $ Administered_Dose1_Pop_Pct             <dbl> 0.0, 72.0, 85.8, 66.5, 69.5, 62…
## $ Administered_Dose1_Recip_5Plus         <dbl> 3545797, 1385254, 832301, 11881…
## $ Administered_Dose1_Recip_5PlusPop_Pct  <dbl> 0.0, 76.8, 90.6, 69.9, 73.6, 66…
## $ Administered_Dose1_Recip_12Plus        <dbl> 3545781, 1321056, 800850, 11585…
## $ Administered_Dose1_Recip_12PlusPop_Pct <dbl> 0.0, 81.7, 95.0, 74.4, 78.2, 72…
## $ Administered_Dose1_Recip_18Plus        <dbl> 3543854, 1221971, 749018, 10956…
## $ Administered_Dose1_Recip_18PlusPop_Pct <dbl> 0.0, 83.8, 95.0, 76.5, 80.5, 75…
## $ Administered_Dose1_Recip_65Plus        <dbl> 1729338, 313542, 218259, 347461…
## $ Administered_Dose1_Recip_65PlusPop_Pct <dbl> 0.0, 95.0, 95.0, 94.7, 95.0, 95…
## $ vxc                                    <dbl> 2988861, 1257663, 694914, 10549…
## $ vxcpoppct                              <dbl> 0.0, 65.0, 71.4, 58.9, 63.2, 55…
## $ Series_Complete_5Plus                  <dbl> 2988790, 1254345, 693868, 10537…
## $ Series_Complete_5PlusPop_Pct           <dbl> 0.0, 69.5, 75.5, 62.0, 67.3, 59…
## $ Series_Complete_12Plus                 <dbl> 2988784, 1198619, 668526, 10302…
## $ Series_Complete_12PlusPop_Pct          <dbl> 0.0, 74.1, 79.6, 66.1, 71.6, 63…
## $ vxcgte18                               <dbl> 2987373, 1108987, 624194, 97492…
## $ vxcgte18pct                            <dbl> 0.0, 76.0, 81.0, 68.1, 73.7, 66…
## $ vxcgte65                               <dbl> 1528522, 292897, 187725, 316675…
## $ vxcgte65pct                            <dbl> 0.0, 93.7, 95.0, 86.3, 94.7, 88…
## $ Series_Complete_Janssen                <dbl> 233980, 89549, 57869, 61920, 16…
## $ Series_Complete_Moderna                <dbl> 1467192, 424332, 242886, 432285…
## $ Series_Complete_Pfizer                 <dbl> 1287661, 741342, 392832, 559945…
## $ Series_Complete_Novavax                <dbl> 24, 59, 29, 30, 50, 91, 651, 28…
## $ Series_Complete_Unk_Manuf              <dbl> 3, 2100, 861, 589, 643, 1010, 4…
## $ Series_Complete_Janssen_5Plus          <dbl> 233974, 89532, 57865, 61903, 16…
## $ Series_Complete_Moderna_5Plus          <dbl> 1467169, 421449, 242494, 431420…
## $ Series_Complete_Pfizer_5Plus           <dbl> 1287620, 741211, 392619, 559781…
## $ Series_Complete_Unk_Manuf_5Plus        <dbl> 3, 2094, 861, 587, 642, 1010, 4…
## $ Series_Complete_Janssen_12Plus         <dbl> 233973, 89519, 57858, 61901, 16…
## $ Series_Complete_Moderna_12Plus         <dbl> 1467168, 421331, 242451, 431343…
## $ Series_Complete_Pfizer_12Plus          <dbl> 1287616, 685669, 367340, 536395…
## $ Series_Complete_Unk_Manuf_12Plus       <dbl> 3, 2041, 848, 572, 606, 1004, 4…
## $ Series_Complete_Janssen_18Plus         <dbl> 233938, 89441, 57808, 61838, 16…
## $ Series_Complete_Moderna_18Plus         <dbl> 1467129, 421072, 242277, 430941…
## $ Series_Complete_Pfizer_18Plus          <dbl> 1286279, 596543, 323272, 481581…
## $ Series_Complete_Unk_Manuf_18Plus       <dbl> 3, 1877, 808, 533, 554, 996, 43…
## $ Series_Complete_Janssen_65Plus         <dbl> 76712, 7058, 10082, 9689, 14679…
## $ Series_Complete_Moderna_65Plus         <dbl> 835134, 141612, 77853, 162729, …
## $ Series_Complete_Pfizer_65Plus          <dbl> 616669, 143226, 99394, 144029, …
## $ Series_Complete_Unk_Manuf_65Plus       <dbl> 2, 993, 393, 223, 163, 373, 227…
## $ Additional_Doses                       <dbl> 1221492, 673360, 339672, 506667…
## $ Additional_Doses_Vax_Pct               <dbl> 40.9, 53.5, 48.9, 48.0, 55.3, 4…
## $ Additional_Doses_5Plus                 <dbl> 1221487, 673298, 339670, 506630…
## $ Additional_Doses_5Plus_Vax_Pct         <dbl> 40.9, 53.7, 49.0, 48.1, 55.4, 4…
## $ Additional_Doses_12Plus                <dbl> 1221486, 662455, 335972, 504088…
## $ Additional_Doses_12Plus_Vax_Pct        <dbl> 40.9, 55.3, 50.3, 48.9, 56.9, 4…
## $ Additional_Doses_18Plus                <dbl> 1221397, 631848, 322036, 491562…
## $ Additional_Doses_18Plus_Vax_Pct        <dbl> 40.9, 57.0, 51.6, 50.4, 58.8, 4…
## $ Additional_Doses_50Plus                <dbl> 1106281, 400915, 227926, 357348…
## $ Additional_Doses_50Plus_Vax_Pct        <dbl> 46.9, 70.2, 63.2, 61.0, 71.9, 6…
## $ Additional_Doses_65Plus                <dbl> 795759, 230950, 135191, 218704,…
## $ Additional_Doses_65Plus_Vax_Pct        <dbl> 52.1, 78.9, 72.0, 69.1, 80.6, 7…
## $ Additional_Doses_Moderna               <dbl> 646719, 255267, 142652, 234519,…
## $ Additional_Doses_Pfizer                <dbl> 553511, 410083, 191595, 266805,…
## $ Additional_Doses_Janssen               <dbl> 21262, 7100, 5321, 5212, 14337,…
## $ Additional_Doses_Unk_Manuf             <dbl> 0, 887, 103, 129, 181, 180, 106…
## $ Second_Booster                         <lgl> NA, NA, NA, NA, NA, NA, NA, NA,…
## $ Second_Booster_50Plus                  <dbl> 289139, 153105, 88562, 115683, …
## $ Second_Booster_50Plus_Vax_Pct          <dbl> 26.1, 38.2, 38.9, 32.4, 40.6, 3…
## $ Second_Booster_65Plus                  <dbl> 226537, 105198, 63069, 82695, 2…
## $ Second_Booster_65Plus_Vax_Pct          <dbl> 28.5, 45.6, 46.7, 37.8, 49.3, 4…
## $ Second_Booster_Janssen                 <dbl> 58, 114, 88, 72, 100, 94, 2151,…
## $ Second_Booster_Moderna                 <dbl> 152100, 62272, 43047, 57960, 14…
## $ Second_Booster_Pfizer                  <dbl> 141364, 105351, 52049, 67207, 1…
## $ Second_Booster_Unk_Manuf               <dbl> 1, 342, 27, 35, 139, 45, 4088, …
## $ Administered_Bivalent                  <lgl> NA, NA, NA, NA, NA, NA, NA, NA,…
## $ Admin_Bivalent_PFR                     <lgl> NA, NA, NA, NA, NA, NA, NA, NA,…
## $ Admin_Bivalent_MOD                     <lgl> NA, NA, NA, NA, NA, NA, NA, NA,…
## $ Dist_Bivalent_PFR                      <lgl> NA, NA, NA, NA, NA, NA, NA, NA,…
## $ Dist_Bivalent_MOD                      <lgl> NA, NA, NA, NA, NA, NA, NA, NA,…
## 
## Column sums before and after applying filtering rules:
## # A tibble: 3 × 6
##   isType tot_cases tot_deaths     new_cases    new_deaths         n
##   <chr>      <dbl>      <dbl>         <dbl>         <dbl>     <dbl>
## 1 before  3.77e+10    5.43e+8 95527960      1036655       57997    
## 2 after   3.75e+10    5.40e+8 94432864      1030862       50133    
## 3 pctchg  7.08e- 3    4.61e-3        0.0115       0.00559     0.136
## 
## 
## Processed for cdcDaily:
## Rows: 50,133
## Columns: 6
## $ date       <date> 2021-03-11, 2021-12-01, 2020-04-08, 2020-02-04, 2021-09-01…
## $ state      <chr> "KS", "ND", "AR", "AR", "ND", "IN", "AR", "AL", "NM", "UT",…
## $ tot_cases  <dbl> 297229, 163565, 1071, 0, 118491, 668765, 56199, 547966, 602…
## $ tot_deaths <dbl> 4851, 1907, 18, 0, 1562, 12710, 674, 11530, 8318, 3787, 107…
## $ new_cases  <dbl> 0, 589, 78, 0, 536, 487, 547, 154, 1509, 0, 2135, 8, 451, 0…
## $ new_deaths <dbl> 0, 9, 0, 0, 1, 7, 11, 5, 6, 0, 100, 0, 5, 0, 0, 7, 8, 39, 1…
## 
## Column sums before and after applying filtering rules:
## # A tibble: 3 × 5
##   isType     inp hosp_adult     hosp_ped          n
##   <chr>    <dbl>      <dbl>        <dbl>      <dbl>
## 1 before 5.19e+7    4.52e+7 1269286      50717     
## 2 after  5.16e+7    4.50e+7 1244077      48456     
## 3 pctchg 5.41e-3    5.18e-3       0.0199     0.0446
## 
## 
## Processed for cdcHosp:
## Rows: 48,456
## Columns: 5
## $ date       <date> 2021-01-13, 2021-01-13, 2021-01-13, 2021-01-10, 2021-01-09…
## $ state      <chr> "DC", "NH", "NV", "RI", "MA", "SD", "RI", "MN", "RI", "SD",…
## $ inp        <dbl> 371, 294, 1817, 449, 2075, 247, 483, 1040, 471, 291, 669, 5…
## $ hosp_adult <dbl> 343, 291, 1810, 446, 2051, 244, 479, 1024, 469, 287, 665, 5…
## $ hosp_ped   <dbl> 28, 3, 7, 3, 24, 3, 4, 16, 2, 4, 4, 108, 2, 1, 0, 7, 0, 1, …
## 
## Column sums before and after applying filtering rules:
## # A tibble: 3 × 9
##   isType      vxa      vxc   vxcpoppct vxcgte65 vxcgt…¹ vxcgte18 vxcgt…²       n
##   <chr>     <dbl>    <dbl>       <dbl>    <dbl>   <dbl>    <dbl>   <dbl>   <dbl>
## 1 before 4.19e+11 1.72e+11 1527989.    4.35e+10 2.26e+6 1.59e+11 1.80e+6 3.64e+4
## 2 after  2.02e+11 8.31e+10 1278920.    2.11e+10 2.00e+6 7.69e+10 1.52e+6 2.88e+4
## 3 pctchg 5.18e- 1 5.16e- 1       0.163 5.16e- 1 1.14e-1 5.16e- 1 1.54e-1 2.09e-1
## # … with abbreviated variable names ¹​vxcgte65pct, ²​vxcgte18pct
## 
## 
## Processed for vax:
## Rows: 28,815
## Columns: 9
## $ date        <date> 2022-09-28, 2022-09-28, 2022-09-28, 2022-09-28, 2022-09-2…
## $ state       <chr> "NE", "DE", "WV", "IA", "ID", "FL", "ND", "AR", "KY", "MI"…
## $ vxa         <dbl> 3451226, 1970701, 2901813, 5515503, 2630561, 39803100, 117…
## $ vxc         <dbl> 1257663, 694914, 1054914, 1994024, 989510, 14697269, 43395…
## $ vxcpoppct   <dbl> 65.0, 71.4, 58.9, 63.2, 55.4, 68.4, 56.9, 55.8, 58.6, 61.4…
## $ vxcgte65    <dbl> 292897, 187725, 316675, 523635, 257641, 4173533, 105759, 4…
## $ vxcgte65pct <dbl> 93.7, 95.0, 86.3, 94.7, 88.6, 92.8, 88.2, 82.3, 87.9, 89.9…
## $ vxcgte18    <dbl> 1108987, 624194, 974923, 1790031, 891754, 13500109, 393211…
## $ vxcgte18pct <dbl> 76.0, 81.0, 68.1, 73.7, 66.6, 78.3, 67.6, 65.5, 68.7, 70.5…
## 
## Integrated per capita data file:
## Rows: 50,346
## Columns: 34
## $ date        <date> 2020-01-01, 2020-01-01, 2020-01-01, 2020-01-01, 2020-01-0…
## $ state       <chr> "AL", "HI", "IN", "LA", "MN", "MT", "NC", "TX", "AL", "HI"…
## $ tot_cases   <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ tot_deaths  <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ new_cases   <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ new_deaths  <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ inp         <dbl> NA, 0, 0, NA, 0, 0, 0, 0, NA, 0, 0, NA, 0, 0, 0, 1877, 0, …
## $ hosp_adult  <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ hosp_ped    <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ vxa         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ vxc         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ vxcpoppct   <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ vxcgte65    <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ vxcgte65pct <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ vxcgte18    <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ vxcgte18pct <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ tcpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ tdpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ cpm         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ dpm         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ hpm         <dbl> NA, 0.0000, 0.0000, NA, 0.0000, 0.0000, 0.0000, 0.0000, NA…
## $ ahpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ phpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ vxapm       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ vxcpm       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ tcpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ tdpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ cpm7        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ dpm7        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ hpm7        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ ahpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ phpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ vxapm7      <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ vxcpm7      <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj =
## prefer_proj): Discarded datum unknown in Proj4 definition

saveToRDS(cdc_daily_221002, ovrWriteError=FALSE)

The function is run to download and process the latest hospitalization data:

# Run for latest data, save as RDS
indivHosp_20221003 <- downloadReadHospitalData(loc="./RInputFiles/Coronavirus/HHS_Hospital_20221003.csv")
## 
## File ./RInputFiles/Coronavirus/HHS_Hospital_20221003.csv already exists
## File will not be downloaded since ovrWrite is not TRUE
## Rows: 260543 Columns: 128
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr   (11): hospital_pk, state, ccn, hospital_name, address, city, zip, hosp...
## dbl  (114): total_beds_7_day_avg, all_adult_hospital_beds_7_day_avg, all_adu...
## lgl    (2): is_metro_micro, is_corrected
## date   (1): collection_week
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
## Rows: 260,543
## Columns: 128
## $ hospital_pk                                                                        <chr> …
## $ collection_week                                                                    <date> …
## $ state                                                                              <chr> …
## $ ccn                                                                                <chr> …
## $ hospital_name                                                                      <chr> …
## $ address                                                                            <chr> …
## $ city                                                                               <chr> …
## $ zip                                                                                <chr> …
## $ hospital_subtype                                                                   <chr> …
## $ fips_code                                                                          <chr> …
## $ is_metro_micro                                                                     <lgl> …
## $ total_beds_7_day_avg                                                               <dbl> …
## $ all_adult_hospital_beds_7_day_avg                                                  <dbl> …
## $ all_adult_hospital_inpatient_beds_7_day_avg                                        <dbl> …
## $ inpatient_beds_used_7_day_avg                                                      <dbl> …
## $ all_adult_hospital_inpatient_bed_occupied_7_day_avg                                <dbl> …
## $ inpatient_beds_used_covid_7_day_avg                                                <dbl> …
## $ total_adult_patients_hospitalized_confirmed_and_suspected_covid_7_day_avg          <dbl> …
## $ total_adult_patients_hospitalized_confirmed_covid_7_day_avg                        <dbl> …
## $ total_pediatric_patients_hospitalized_confirmed_and_suspected_covid_7_day_avg      <dbl> …
## $ total_pediatric_patients_hospitalized_confirmed_covid_7_day_avg                    <dbl> …
## $ inpatient_beds_7_day_avg                                                           <dbl> …
## $ total_icu_beds_7_day_avg                                                           <dbl> …
## $ total_staffed_adult_icu_beds_7_day_avg                                             <dbl> …
## $ icu_beds_used_7_day_avg                                                            <dbl> …
## $ staffed_adult_icu_bed_occupancy_7_day_avg                                          <dbl> …
## $ staffed_icu_adult_patients_confirmed_and_suspected_covid_7_day_avg                 <dbl> …
## $ staffed_icu_adult_patients_confirmed_covid_7_day_avg                               <dbl> …
## $ total_patients_hospitalized_confirmed_influenza_7_day_avg                          <dbl> …
## $ icu_patients_confirmed_influenza_7_day_avg                                         <dbl> …
## $ total_patients_hospitalized_confirmed_influenza_and_covid_7_day_avg                <dbl> …
## $ total_beds_7_day_sum                                                               <dbl> …
## $ all_adult_hospital_beds_7_day_sum                                                  <dbl> …
## $ all_adult_hospital_inpatient_beds_7_day_sum                                        <dbl> …
## $ inpatient_beds_used_7_day_sum                                                      <dbl> …
## $ all_adult_hospital_inpatient_bed_occupied_7_day_sum                                <dbl> …
## $ inpatient_beds_used_covid_7_day_sum                                                <dbl> …
## $ total_adult_patients_hospitalized_confirmed_and_suspected_covid_7_day_sum          <dbl> …
## $ total_adult_patients_hospitalized_confirmed_covid_7_day_sum                        <dbl> …
## $ total_pediatric_patients_hospitalized_confirmed_and_suspected_covid_7_day_sum      <dbl> …
## $ total_pediatric_patients_hospitalized_confirmed_covid_7_day_sum                    <dbl> …
## $ inpatient_beds_7_day_sum                                                           <dbl> …
## $ total_icu_beds_7_day_sum                                                           <dbl> …
## $ total_staffed_adult_icu_beds_7_day_sum                                             <dbl> …
## $ icu_beds_used_7_day_sum                                                            <dbl> …
## $ staffed_adult_icu_bed_occupancy_7_day_sum                                          <dbl> …
## $ staffed_icu_adult_patients_confirmed_and_suspected_covid_7_day_sum                 <dbl> …
## $ staffed_icu_adult_patients_confirmed_covid_7_day_sum                               <dbl> …
## $ total_patients_hospitalized_confirmed_influenza_7_day_sum                          <dbl> …
## $ icu_patients_confirmed_influenza_7_day_sum                                         <dbl> …
## $ total_patients_hospitalized_confirmed_influenza_and_covid_7_day_sum                <dbl> …
## $ total_beds_7_day_coverage                                                          <dbl> …
## $ all_adult_hospital_beds_7_day_coverage                                             <dbl> …
## $ all_adult_hospital_inpatient_beds_7_day_coverage                                   <dbl> …
## $ inpatient_beds_used_7_day_coverage                                                 <dbl> …
## $ all_adult_hospital_inpatient_bed_occupied_7_day_coverage                           <dbl> …
## $ inpatient_beds_used_covid_7_day_coverage                                           <dbl> …
## $ total_adult_patients_hospitalized_confirmed_and_suspected_covid_7_day_coverage     <dbl> …
## $ total_adult_patients_hospitalized_confirmed_covid_7_day_coverage                   <dbl> …
## $ total_pediatric_patients_hospitalized_confirmed_and_suspected_covid_7_day_coverage <dbl> …
## $ total_pediatric_patients_hospitalized_confirmed_covid_7_day_coverage               <dbl> …
## $ inpatient_beds_7_day_coverage                                                      <dbl> …
## $ total_icu_beds_7_day_coverage                                                      <dbl> …
## $ total_staffed_adult_icu_beds_7_day_coverage                                        <dbl> …
## $ icu_beds_used_7_day_coverage                                                       <dbl> …
## $ staffed_adult_icu_bed_occupancy_7_day_coverage                                     <dbl> …
## $ staffed_icu_adult_patients_confirmed_and_suspected_covid_7_day_coverage            <dbl> …
## $ staffed_icu_adult_patients_confirmed_covid_7_day_coverage                          <dbl> …
## $ total_patients_hospitalized_confirmed_influenza_7_day_coverage                     <dbl> …
## $ icu_patients_confirmed_influenza_7_day_coverage                                    <dbl> …
## $ total_patients_hospitalized_confirmed_influenza_and_covid_7_day_coverage           <dbl> …
## $ previous_day_admission_adult_covid_confirmed_7_day_sum                             <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_18-19_7_day_sum`                     <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_20-29_7_day_sum`                     <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_30-39_7_day_sum`                     <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_40-49_7_day_sum`                     <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_50-59_7_day_sum`                     <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_60-69_7_day_sum`                     <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_70-79_7_day_sum`                     <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_80+_7_day_sum`                       <dbl> …
## $ previous_day_admission_adult_covid_confirmed_unknown_7_day_sum                     <dbl> …
## $ previous_day_admission_pediatric_covid_confirmed_7_day_sum                         <dbl> …
## $ previous_day_covid_ED_visits_7_day_sum                                             <dbl> …
## $ previous_day_admission_adult_covid_suspected_7_day_sum                             <dbl> …
## $ `previous_day_admission_adult_covid_suspected_18-19_7_day_sum`                     <dbl> …
## $ `previous_day_admission_adult_covid_suspected_20-29_7_day_sum`                     <dbl> …
## $ `previous_day_admission_adult_covid_suspected_30-39_7_day_sum`                     <dbl> …
## $ `previous_day_admission_adult_covid_suspected_40-49_7_day_sum`                     <dbl> …
## $ `previous_day_admission_adult_covid_suspected_50-59_7_day_sum`                     <dbl> …
## $ `previous_day_admission_adult_covid_suspected_60-69_7_day_sum`                     <dbl> …
## $ `previous_day_admission_adult_covid_suspected_70-79_7_day_sum`                     <dbl> …
## $ `previous_day_admission_adult_covid_suspected_80+_7_day_sum`                       <dbl> …
## $ previous_day_admission_adult_covid_suspected_unknown_7_day_sum                     <dbl> …
## $ previous_day_admission_pediatric_covid_suspected_7_day_sum                         <dbl> …
## $ previous_day_total_ED_visits_7_day_sum                                             <dbl> …
## $ previous_day_admission_influenza_confirmed_7_day_sum                               <dbl> …
## $ geocoded_hospital_address                                                          <chr> …
## $ hhs_ids                                                                            <chr> …
## $ previous_day_admission_adult_covid_confirmed_7_day_coverage                        <dbl> …
## $ previous_day_admission_pediatric_covid_confirmed_7_day_coverage                    <dbl> …
## $ previous_day_admission_adult_covid_suspected_7_day_coverage                        <dbl> …
## $ previous_day_admission_pediatric_covid_suspected_7_day_coverage                    <dbl> …
## $ previous_week_personnel_covid_vaccinated_doses_administered_7_day                  <dbl> …
## $ total_personnel_covid_vaccinated_doses_none_7_day                                  <dbl> …
## $ total_personnel_covid_vaccinated_doses_one_7_day                                   <dbl> …
## $ total_personnel_covid_vaccinated_doses_all_7_day                                   <dbl> …
## $ previous_week_patients_covid_vaccinated_doses_one_7_day                            <dbl> …
## $ previous_week_patients_covid_vaccinated_doses_all_7_day                            <dbl> …
## $ is_corrected                                                                       <lgl> …
## $ all_pediatric_inpatient_bed_occupied_7_day_avg                                     <dbl> …
## $ all_pediatric_inpatient_bed_occupied_7_day_coverage                                <dbl> …
## $ all_pediatric_inpatient_bed_occupied_7_day_sum                                     <dbl> …
## $ all_pediatric_inpatient_beds_7_day_avg                                             <dbl> …
## $ all_pediatric_inpatient_beds_7_day_coverage                                        <dbl> …
## $ all_pediatric_inpatient_beds_7_day_sum                                             <dbl> …
## $ previous_day_admission_pediatric_covid_confirmed_0_4_7_day_sum                     <dbl> …
## $ previous_day_admission_pediatric_covid_confirmed_12_17_7_day_sum                   <dbl> …
## $ previous_day_admission_pediatric_covid_confirmed_5_11_7_day_sum                    <dbl> …
## $ previous_day_admission_pediatric_covid_confirmed_unknown_7_day_sum                 <dbl> …
## $ staffed_icu_pediatric_patients_confirmed_covid_7_day_avg                           <dbl> …
## $ staffed_icu_pediatric_patients_confirmed_covid_7_day_coverage                      <dbl> …
## $ staffed_icu_pediatric_patients_confirmed_covid_7_day_sum                           <dbl> …
## $ staffed_pediatric_icu_bed_occupancy_7_day_avg                                      <dbl> …
## $ staffed_pediatric_icu_bed_occupancy_7_day_coverage                                 <dbl> …
## $ staffed_pediatric_icu_bed_occupancy_7_day_sum                                      <dbl> …
## $ total_staffed_pediatric_icu_beds_7_day_avg                                         <dbl> …
## $ total_staffed_pediatric_icu_beds_7_day_coverage                                    <dbl> …
## $ total_staffed_pediatric_icu_beds_7_day_sum                                         <dbl> …
## 
## Hospital Subtype Counts:
## # A tibble: 4 × 2
##   hospital_subtype               n
##   <chr>                      <int>
## 1 Childrens Hospitals         4909
## 2 Critical Access Hospitals  69937
## 3 Long Term                  17869
## 4 Short Term                167828
## 
## Records other than 50 states and DC
## # A tibble: 5 × 2
##   state     n
##   <chr> <int>
## 1 AS       52
## 2 GU      102
## 3 MP       40
## 4 PR     2766
## 5 VI      104
## 
## Record types for key metrics
## # A tibble: 10 × 5
##    name                                              `NA` Posit…¹ Value…²  Total
##    <chr>                                            <int>   <int>   <int>  <int>
##  1 all_adult_hospital_beds_7_day_avg                71194  188847     502 260543
##  2 all_adult_hospital_inpatient_bed_occupied_7_day…   131  238657   21755 260543
##  3 icu_beds_used_7_day_avg                             56  228646   31841 260543
##  4 inpatient_beds_7_day_avg                            46  259479    1018 260543
##  5 inpatient_beds_used_7_day_avg                       35  239484   21024 260543
##  6 inpatient_beds_used_covid_7_day_avg                 26  173367   87150 260543
##  7 staffed_icu_adult_patients_confirmed_and_suspec…   169  174858   85516 260543
##  8 total_adult_patients_hospitalized_confirmed_and…   127  173350   87066 260543
##  9 total_beds_7_day_avg                             69419  190826     298 260543
## 10 total_icu_beds_7_day_avg                            58  246878   13607 260543
## # … with abbreviated variable names ¹​Positive, ²​`Value -999999`
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

saveToRDS(indivHosp_20221003, ovrWriteError=FALSE)

Post-processing is run, including hospital summaries:

# Create pivoted burden data
burdenPivotList_221002 <- postProcessCDCDaily(cdc_daily_221002, 
                                              dataThruLabel="Sep 2022", 
                                              keyDatesBurden=c("2022-09-30", "2022-03-31", 
                                                               "2021-09-30", "2021-03-31"
                                                               ),
                                              keyDatesVaccine=c("2022-09-28", "2022-03-31", 
                                                                "2021-09-30", "2021-03-31"
                                                                ), 
                                              returnData=TRUE
                                              )
## Joining, by = "state"
## 
## *** File has been checked for uniqueness by: state date name
## Warning: Removed 24 row(s) containing missing values (geom_path).

## Warning: Removed 24 rows containing missing values (position_stack).

## Warning: Removed 24 rows containing missing values (position_stack).

## Warning: Removed 9 row(s) containing missing values (geom_path).

# Create hospitalized per capita data
hospPerCap_221002 <- hospAgePerCapita(readFromRDS("dfStateAgeBucket2019"), 
                                      lst=burdenPivotList_221002, 
                                      popVar="pop2019", 
                                      excludeState=c(), 
                                      cumStartDate="2020-07-15"
                                      )
## Warning: Removed 18 row(s) containing missing values (geom_path).

burdenPivotList_221002$hospAge %>%
    group_by(adultPed, confSusp, age, name) %>%
    summarize(value=sum(value, na.rm=TRUE), n=n(), .groups="drop")
## # A tibble: 18 × 6
##    adultPed confSusp  age   name                                     value     n
##    <chr>    <chr>     <chr> <chr>                                    <dbl> <int>
##  1 adult    confirmed 0-19  previous_day_admission_adult_covid_con… 4.77e4 50717
##  2 adult    confirmed 20-29 previous_day_admission_adult_covid_con… 2.90e5 50717
##  3 adult    confirmed 30-39 previous_day_admission_adult_covid_con… 4.19e5 50717
##  4 adult    confirmed 40-49 previous_day_admission_adult_covid_con… 5.02e5 50717
##  5 adult    confirmed 50-59 previous_day_admission_adult_covid_con… 8.01e5 50717
##  6 adult    confirmed 60-69 previous_day_admission_adult_covid_con… 1.05e6 50717
##  7 adult    confirmed 70-79 previous_day_admission_adult_covid_con… 1.06e6 50717
##  8 adult    confirmed 80+   previous_day_admission_adult_covid_con… 9.58e5 50717
##  9 adult    suspected 0-19  previous_day_admission_adult_covid_sus… 3.91e4 50717
## 10 adult    suspected 20-29 previous_day_admission_adult_covid_sus… 2.61e5 50717
## 11 adult    suspected 30-39 previous_day_admission_adult_covid_sus… 3.43e5 50717
## 12 adult    suspected 40-49 previous_day_admission_adult_covid_sus… 3.47e5 50717
## 13 adult    suspected 50-59 previous_day_admission_adult_covid_sus… 5.48e5 50717
## 14 adult    suspected 60-69 previous_day_admission_adult_covid_sus… 7.55e5 50717
## 15 adult    suspected 70-79 previous_day_admission_adult_covid_sus… 7.36e5 50717
## 16 adult    suspected 80+   previous_day_admission_adult_covid_sus… 6.70e5 50717
## 17 ped      confirmed 0-19  previous_day_admission_pediatric_covid… 1.73e5 50717
## 18 ped      suspected 0-19  previous_day_admission_pediatric_covid… 3.88e5 50717
saveToRDS(burdenPivotList_221002, ovrWriteError=FALSE)
saveToRDS(hospPerCap_221002, ovrWriteError=FALSE)

Peaks and valleys of key metrics are also updated:

peakValleyCDCDaily(cdc_daily_221002)
## Warning: Removed 6 row(s) containing missing values (geom_path).

## Warning: Removed 6 row(s) containing missing values (geom_path).

## Warning: Removed 6 row(s) containing missing values (geom_path).

## Warning: Removed 20 row(s) containing missing values (geom_path).

## Warning: Removed 20 row(s) containing missing values (geom_path).

## # A tibble: 8,040 × 8
##    date       state   vxa   vxc vxa_isPeak vxc_isPeak vxa_isValley vxc_isValley
##    <date>     <chr> <dbl> <dbl> <lgl>      <lgl>      <lgl>        <lgl>       
##  1 2020-12-01 CA       NA    NA FALSE      FALSE      FALSE        FALSE       
##  2 2020-12-01 FL       NA    NA FALSE      FALSE      FALSE        FALSE       
##  3 2020-12-01 GA       NA    NA FALSE      FALSE      FALSE        FALSE       
##  4 2020-12-01 IL       NA    NA FALSE      FALSE      FALSE        FALSE       
##  5 2020-12-01 MI       NA    NA FALSE      FALSE      FALSE        FALSE       
##  6 2020-12-01 NC       NA    NA FALSE      FALSE      FALSE        FALSE       
##  7 2020-12-01 NJ       NA    NA FALSE      FALSE      FALSE        FALSE       
##  8 2020-12-01 NY       NA    NA FALSE      FALSE      FALSE        FALSE       
##  9 2020-12-01 OH       NA    NA FALSE      FALSE      FALSE        FALSE       
## 10 2020-12-01 PA       NA    NA FALSE      FALSE      FALSE        FALSE       
## # … with 8,030 more rows
## # ℹ Use `print(n = ...)` to see more rows

A function is written for the hospital data availability checks:

checkHospitalDataComplete <- function(df1=NULL, 
                                      df2=NULL,
                                      dfAll=NULL,
                                      lab1="DF1", 
                                      lab2="DF2", 
                                      trendBreaks=c(), 
                                      makeP1=TRUE, 
                                      makeP2=TRUE,
                                      returnData=FALSE
                                      ) {
    
    # FUNCTION ARGUMENTS:
    # df1: the first data frame (NULL means integrated frame passed as dfAll)
    # df2: the second data frame (NULL means integrated frame passed as dfAll)
    # dfAll: integrated data frame from previous iteration of function (will ignore df1 and df2)
    # lab1: plot label for the first data frame
    # lab2: plot label for the second data frame
    # trendBreaks: character vector of trend break dates of form YYYY-MM-DD - if c(), no trend brek vlines plotted
    # makeP1: boolean, should the first plot be created and printed?
    # makeP2: boolean, should the first plot be created and printed?
    # returnData: boolean, should dfAll be returned?
    
    # Temporary function to aggregate data
    tempCountComplete <- function(df) {
        df %>%
            select(hospital_pk, collection_week, all_of(names(hhsMapper))) %>%
            colRenamer(vecRename=hhsMapper) %>%
            pivot_longer(-c(hospital_pk, collection_week)) %>%
            filter(!is.na(value), value>0) %>%
            count(collection_week, name)
    }
    
    # Create or use passed data
    if(is.null(dfAll)) {
        if(is.null(df1) | is.null(df2)) stop("dfAll not passed requires both df1 and df2 to be passed\n")
        dfAll <- bind_rows(tempCountComplete(df1), tempCountComplete(df2), .id="src")
    } else {
        if(!is.null(df1) | !is.null(df2)) warning("dfAll passed and will be used; df1 and/or df2 ignored\n")
    }
    
    # Plot data completeness - hospitals reporting >0 on metric by week
    if(isTRUE(makeP1)) {
        p1 <- dfAll %>%
            select(collection_week, name) %>%
            unique() %>%
            bind_rows(., ., .id="src")  %>%
            full_join(dfAll, by=c("src", "collection_week", "name")) %>%
            mutate(src=c("1"=lab1, "2"=lab2)[src]) %>%
            mutate(n=ifelse(is.na(n), 0, n)) %>%
            ggplot(aes(x=collection_week, y=n)) +
            geom_line(aes(group=src, color=src)) + 
            facet_wrap(~name) + 
            labs(title="Number of hospitals in US reporting >0 on metric by week", 
                 x=NULL, 
                 y="# Hospitals Reporting > 0"
                 ) + 
            scale_color_discrete("Data Source:")
        if(length(trendBreaks) > 0) {
            p1 <- p1 + geom_vline(xintercept=as.Date(all_of(trendBreaks)), lty=2) +
                labs(subtitle=paste0("Trend break dashed lines at ", 
                                     paste0(all_of(trendBreaks), collapse=" and ")
                                     )
                     )
        }
        print(p1)
    }
    

    # Plot data completeness - showing difference in reported data and trend break dates
    if(isTRUE(makeP2)) {
        p2 <- dfAll %>%
            select(collection_week, name) %>%
            unique() %>%
            bind_rows(., ., .id="src")  %>%
            full_join(dfAll, by=c("src", "collection_week", "name")) %>%
            mutate(src=c("1"=lab1, "2"=lab2)[src]) %>%
            mutate(n=ifelse(is.na(n), 0, n)) %>% 
            group_by(collection_week, name) %>% 
            summarize(delta=sum(ifelse(src==lab1, n, 0)-ifelse(src!=lab1, n, 0)), .groups="drop") %>%
            ggplot(aes(x=collection_week, y=delta)) +
            geom_line() +
            geom_point(data=~filter(., delta != 0), 
                       aes(color=case_when(delta>=0 ~ "darkgreen", TRUE ~ "red"))
                       ) +
            geom_hline(yintercept=0, lty=2) +
            scale_color_identity(NULL) +
            facet_wrap(~name) + 
            labs(title="Delta in Number of hospitals in US reporting >0 on metric by week", 
                 x=NULL, 
                 y="Delta in # Hospitals Reporting > 0"
                 )
        if(length(trendBreaks) > 0) {
            p2 <- p2 + geom_vline(xintercept=as.Date(all_of(trendBreaks)), lty=2) +
                labs(subtitle=paste0("Trend break dashed lines at ", 
                                     paste0(all_of(trendBreaks), collapse=" and ")
                                     )
                )
        }
        print(p2)
    }
    
    if(isTRUE(returnData)) return(dfAll)
    
}

# Create the data
dfTemp <- checkHospitalDataComplete(df1=readFromRDS("indivHosp_20221003"), 
                                    df2=readFromRDS("indivHosp_20220704"), 
                                    makeP1=FALSE, 
                                    makeP2=FALSE,
                                    returnData=TRUE
                                    )

# Create the first plot
checkHospitalDataComplete(dfAll=dfTemp,
                          lab1="OCT-2022", 
                          lab2="JUL-2022", 
                          makeP2=FALSE, 
                          trendBreaks=c("2021-09-25", "2022-06-24")
                          )

# Create the second plot
checkHospitalDataComplete(dfAll=dfTemp,
                          lab1="OCT-2022", 
                          lab2="JUL-2022", 
                          makeP1=FALSE, 
                          trendBreaks=c("2021-09-25", "2022-06-24")
                          )

The discontinuity issues due to occasional minor changes between positive and negative is resolved by using points colored by positive/negative and a solid line

Hospital data are pieced together as needed:

# Create modified hospital data
multiSourceHosp_20221002 <- multiSourceDataCombine(list(readFromRDS("indivHosp_20220704"),
                                                        readFromRDS("indivHosp_20221003")
                                                        ),
                                                   timeVec=as.Date("2022-01-01")
                                                   )

The updated hospital data are then plotted:

# Run hospital plots
modStateHosp_20221002 <- hospitalCapacityCDCDaily(multiSourceHosp_20221002, 
                                                  plotSub="Aug 2020 to Sep 2022\nOld data used pre-2022"
                                                  )

Data From 2022-11-02

The latest CDC case, hospitalization, and death data are downloaded and processed:

readList <- list("cdcDaily"="./RInputFiles/Coronavirus/CDC_dc_downloaded_221102.csv", 
                 "cdcHosp"="./RInputFiles/Coronavirus/CDC_h_downloaded_221102.csv", 
                 "vax"="./RInputFiles/Coronavirus/vaxData_downloaded_221102.csv"
                 )
compareList <- list("cdcDaily"=readFromRDS("cdc_daily_221002")$dfRaw$cdcDaily, 
                    "cdcHosp"=readFromRDS("cdc_daily_221002")$dfRaw$cdcHosp, 
                    "vax"=readFromRDS("cdc_daily_221002")$dfRaw$vax
                    )

cdc_daily_221102 <- readRunCDCDaily(thruLabel="Oct 31, 2022", 
                                    downloadTo=lapply(readList, FUN=function(x) if(file.exists(x)) NA else x), 
                                    readFrom=readList,
                                    compareFile=compareList, 
                                    writeLog=NULL, 
                                    useClusters=readFromRDS("cdc_daily_210528")$useClusters, 
                                    weightedMeanAggs=c("tcpm7", "tdpm7", "cpm7", "dpm7", "hpm7", 
                                                       "vxcpm7", "vxcgte65pct"
                                                       ),
                                    skipAssessmentPlots=FALSE, 
                                    brewPalette="Paired"
                                    )
## Rows: 60060 Columns: 15
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr  (5): submission_date, state, created_at, consent_cases, consent_deaths
## dbl (10): tot_cases, conf_cases, prob_cases, new_case, pnew_case, tot_death,...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
## 
## *** File has been checked for uniqueness by: state date

## 
## 
## Checking for similarity of: column names
## In reference but not in current: 
## In current but not in reference: 
## 
## Checking for similarity of: date
## In reference but not in current: 0
## In current but not in reference: 18
## 
## Checking for similarity of: state
## In reference but not in current: 
## In current but not in reference:

## 
## 
## ***Differences of at least 5 and at least 5%
## 
##          date       name newValue refValue absDelta   pctDelta
## 1  2022-09-25 new_deaths       92       38       54 0.83076923
## 2  2022-09-24 new_deaths      111       81       30 0.31250000
## 3  2022-09-18 new_deaths       83       68       15 0.19867550
## 4  2022-09-26 new_deaths      233      198       35 0.16241299
## 5  2022-09-17 new_deaths      103       89       14 0.14583333
## 6  2022-09-30 new_deaths      370      321       49 0.14182344
## 7  2022-09-10 new_deaths      140      122       18 0.13740458
## 8  2022-08-28 new_deaths      131      117       14 0.11290323
## 9  2022-09-27 new_deaths      470      429       41 0.09121246
## 10 2022-09-23 new_deaths      355      327       28 0.08211144
## 11 2022-08-21 new_deaths      132      122       10 0.07874016
## 12 2022-09-19 new_deaths      228      211       17 0.07744875
## 13 2022-09-05 new_deaths      114      106        8 0.07272727
## 14 2022-08-20 new_deaths      149      139       10 0.06944444
## 15 2022-09-29 new_deaths      605      570       35 0.05957447
## 16 2022-08-27 new_deaths      172      163        9 0.05373134
## 17 2022-09-03 new_deaths      122      116        6 0.05042017
## 18 2022-09-30  new_cases    49011    46391     2620 0.05492547
## 19 2022-09-28  new_cases    67106    63713     3393 0.05187320

## 
## 
## ***Differences of at least 0 and at least 0.1%
## 
##   state       name newValue refValue absDelta    pctDelta
## 1    NC new_deaths    26857    26531      326 0.012212482
## 2    ND new_deaths     2375     2364       11 0.004642330
## 3    FL new_deaths    81756    81441      315 0.003860365
## 4    AL new_deaths    20498    20423       75 0.003665600
## 5   NYC new_deaths    41934    41977       43 0.001024895
## 6    NC  new_cases  3207665  3200475     7190 0.002244021
## 7    SC  new_cases  1711020  1708074     2946 0.001723264
## 
## 
## 
## Raw file for cdcDaily:
## Rows: 60,060
## Columns: 15
## $ date           <date> 2021-03-11, 2021-12-01, 2022-01-02, 2021-11-22, 2022-0…
## $ state          <chr> "KS", "ND", "AS", "AL", "AK", "RMI", "ND", "PR", "PW", …
## $ tot_cases      <dbl> 297229, 163565, 11, 841461, 251425, 0, 173, 173967, 0, …
## $ conf_cases     <dbl> 241035, 135705, NA, 620483, NA, 0, NA, 144788, NA, NA, …
## $ prob_cases     <dbl> 56194, 27860, NA, 220978, NA, 0, NA, 29179, NA, NA, 0, …
## $ new_cases      <dbl> 0, 589, 0, 703, 0, 0, 14, 667, 0, 1509, 0, 28, 2293, 59…
## $ pnew_case      <dbl> 0, 220, 0, 357, 0, 0, NA, 274, 0, 0, 0, 5, 552, 1266, 7…
## $ tot_deaths     <dbl> 4851, 1907, 0, 16377, 1252, 0, 3, 2911, 0, 8318, 3787, …
## $ conf_death     <dbl> NA, NA, NA, 12727, NA, 0, NA, 2482, NA, NA, 3635, 1601,…
## $ prob_death     <dbl> NA, NA, NA, 3650, NA, 0, NA, 429, NA, NA, 152, 366, 0, …
## $ new_deaths     <dbl> 0, 9, 0, 7, 0, 0, 0, 8, 0, 6, 0, 0, 0, 8, 0, 4, 0, 0, 1…
## $ pnew_death     <dbl> 0, 0, 0, 3, 0, 0, NA, 3, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0,…
## $ created_at     <chr> "03/12/2021 03:20:13 PM", "12/02/2021 02:35:20 PM", "01…
## $ consent_cases  <chr> "Agree", "Agree", NA, "Agree", "N/A", "Agree", "Agree",…
## $ consent_deaths <chr> "N/A", "Not agree", NA, "Agree", "N/A", "Agree", "Not a…
## Rows: 52391 Columns: 135
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr    (1): state
## dbl  (132): critical_staffing_shortage_today_yes, critical_staffing_shortage...
## lgl    (1): geocoded_state
## date   (1): date
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.

## 
## *** File has been checked for uniqueness by: state date

## 
## 
## Checking for similarity of: column names
## In reference but not in current: 
## In current but not in reference: 
## 
## Checking for similarity of: date
## In reference but not in current: 0
## In current but not in reference: 31
## 
## Checking for similarity of: state
## In reference but not in current: 
## In current but not in reference:

## 
## 
## ***Differences of at least 5 and at least 5%
## 
##         date     name newValue refValue absDelta  pctDelta
## 1 2020-08-02 hosp_ped     6791     4561     2230 0.3928823

## 
## 
## ***Differences of at least 0 and at least 0.1%
## 
##    state       name newValue refValue absDelta    pctDelta
## 1     NV        inp   669396   670631     1235 0.001843246
## 2     NH   hosp_ped     1328     1282       46 0.035249042
## 3     WV   hosp_ped     6407     6206      201 0.031871878
## 4     ME   hosp_ped     2722     2675       47 0.017417084
## 5     MA   hosp_ped    14134    13890      244 0.017413645
## 6     NV   hosp_ped     5928     5831       97 0.016498002
## 7     VI   hosp_ped      128      130        2 0.015503876
## 8     SC   hosp_ped    10059     9955      104 0.010392725
## 9     AR   hosp_ped    14079    13965      114 0.008130081
## 10    AZ   hosp_ped    29543    29312      231 0.007849800
## 11    TN   hosp_ped    24231    24060      171 0.007082065
## 12    AL   hosp_ped    22626    22485      141 0.006251247
## 13    VT   hosp_ped      658      654        4 0.006097561
## 14    UT   hosp_ped    11316    11255       61 0.005405166
## 15    NM   hosp_ped     8584     8545       39 0.004553681
## 16    IN   hosp_ped    18602    18682       80 0.004291385
## 17    KS   hosp_ped     5308     5288       20 0.003775009
## 18    PR   hosp_ped    25141    25055       86 0.003426568
## 19    CO   hosp_ped    23478    23402       76 0.003242321
## 20    FL   hosp_ped    97891    97593      298 0.003048843
## 21    MS   hosp_ped    12979    13017       38 0.002923527
## 22    KY   hosp_ped    22910    22845       65 0.002841220
## 23    NJ   hosp_ped    20956    20999       43 0.002049815
## 24    IA   hosp_ped     8413     8430       17 0.002018643
## 25    PA   hosp_ped    59345    59227      118 0.001990352
## 26    GA   hosp_ped    57694    57605       89 0.001543812
## 27    OK   hosp_ped    28563    28528       35 0.001226113
## 28    MO   hosp_ped    43011    43059       48 0.001115371
## 29    IL   hosp_ped    47538    47488       50 0.001052344
## 30    OR   hosp_ped    12762    12749       13 0.001019168
## 31    NV hosp_adult   616917   618249     1332 0.002156795
## 32    WV hosp_adult   345523   345909      386 0.001116523
## 
## 
## 
## Raw file for cdcHosp:
## Rows: 52,391
## Columns: 135
## $ state                                                                        <chr> …
## $ date                                                                         <date> …
## $ critical_staffing_shortage_today_yes                                         <dbl> …
## $ critical_staffing_shortage_today_no                                          <dbl> …
## $ critical_staffing_shortage_today_not_reported                                <dbl> …
## $ critical_staffing_shortage_anticipated_within_week_yes                       <dbl> …
## $ critical_staffing_shortage_anticipated_within_week_no                        <dbl> …
## $ critical_staffing_shortage_anticipated_within_week_not_reported              <dbl> …
## $ hospital_onset_covid                                                         <dbl> …
## $ hospital_onset_covid_coverage                                                <dbl> …
## $ inpatient_beds                                                               <dbl> …
## $ inpatient_beds_coverage                                                      <dbl> …
## $ inpatient_beds_used                                                          <dbl> …
## $ inpatient_beds_used_coverage                                                 <dbl> …
## $ inp                                                                          <dbl> …
## $ inpatient_beds_used_covid_coverage                                           <dbl> …
## $ previous_day_admission_adult_covid_confirmed                                 <dbl> …
## $ previous_day_admission_adult_covid_confirmed_coverage                        <dbl> …
## $ previous_day_admission_adult_covid_suspected                                 <dbl> …
## $ previous_day_admission_adult_covid_suspected_coverage                        <dbl> …
## $ previous_day_admission_pediatric_covid_confirmed                             <dbl> …
## $ previous_day_admission_pediatric_covid_confirmed_coverage                    <dbl> …
## $ previous_day_admission_pediatric_covid_suspected                             <dbl> …
## $ previous_day_admission_pediatric_covid_suspected_coverage                    <dbl> …
## $ staffed_adult_icu_bed_occupancy                                              <dbl> …
## $ staffed_adult_icu_bed_occupancy_coverage                                     <dbl> …
## $ staffed_icu_adult_patients_confirmed_and_suspected_covid                     <dbl> …
## $ staffed_icu_adult_patients_confirmed_and_suspected_covid_coverage            <dbl> …
## $ staffed_icu_adult_patients_confirmed_covid                                   <dbl> …
## $ staffed_icu_adult_patients_confirmed_covid_coverage                          <dbl> …
## $ hosp_adult                                                                   <dbl> …
## $ total_adult_patients_hospitalized_confirmed_and_suspected_covid_coverage     <dbl> …
## $ total_adult_patients_hospitalized_confirmed_covid                            <dbl> …
## $ total_adult_patients_hospitalized_confirmed_covid_coverage                   <dbl> …
## $ hosp_ped                                                                     <dbl> …
## $ total_pediatric_patients_hospitalized_confirmed_and_suspected_covid_coverage <dbl> …
## $ total_pediatric_patients_hospitalized_confirmed_covid                        <dbl> …
## $ total_pediatric_patients_hospitalized_confirmed_covid_coverage               <dbl> …
## $ total_staffed_adult_icu_beds                                                 <dbl> …
## $ total_staffed_adult_icu_beds_coverage                                        <dbl> …
## $ inpatient_beds_utilization                                                   <dbl> …
## $ inpatient_beds_utilization_coverage                                          <dbl> …
## $ inpatient_beds_utilization_numerator                                         <dbl> …
## $ inpatient_beds_utilization_denominator                                       <dbl> …
## $ percent_of_inpatients_with_covid                                             <dbl> …
## $ percent_of_inpatients_with_covid_coverage                                    <dbl> …
## $ percent_of_inpatients_with_covid_numerator                                   <dbl> …
## $ percent_of_inpatients_with_covid_denominator                                 <dbl> …
## $ inpatient_bed_covid_utilization                                              <dbl> …
## $ inpatient_bed_covid_utilization_coverage                                     <dbl> …
## $ inpatient_bed_covid_utilization_numerator                                    <dbl> …
## $ inpatient_bed_covid_utilization_denominator                                  <dbl> …
## $ adult_icu_bed_covid_utilization                                              <dbl> …
## $ adult_icu_bed_covid_utilization_coverage                                     <dbl> …
## $ adult_icu_bed_covid_utilization_numerator                                    <dbl> …
## $ adult_icu_bed_covid_utilization_denominator                                  <dbl> …
## $ adult_icu_bed_utilization                                                    <dbl> …
## $ adult_icu_bed_utilization_coverage                                           <dbl> …
## $ adult_icu_bed_utilization_numerator                                          <dbl> …
## $ adult_icu_bed_utilization_denominator                                        <dbl> …
## $ geocoded_state                                                               <lgl> …
## $ `previous_day_admission_adult_covid_confirmed_18-19`                         <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_18-19_coverage`                <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_20-29`                         <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_20-29_coverage`                <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_30-39`                         <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_30-39_coverage`                <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_40-49`                         <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_40-49_coverage`                <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_50-59`                         <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_50-59_coverage`                <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_60-69`                         <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_60-69_coverage`                <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_70-79`                         <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_70-79_coverage`                <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_80+`                           <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_80+_coverage`                  <dbl> …
## $ previous_day_admission_adult_covid_confirmed_unknown                         <dbl> …
## $ previous_day_admission_adult_covid_confirmed_unknown_coverage                <dbl> …
## $ `previous_day_admission_adult_covid_suspected_18-19`                         <dbl> …
## $ `previous_day_admission_adult_covid_suspected_18-19_coverage`                <dbl> …
## $ `previous_day_admission_adult_covid_suspected_20-29`                         <dbl> …
## $ `previous_day_admission_adult_covid_suspected_20-29_coverage`                <dbl> …
## $ `previous_day_admission_adult_covid_suspected_30-39`                         <dbl> …
## $ `previous_day_admission_adult_covid_suspected_30-39_coverage`                <dbl> …
## $ `previous_day_admission_adult_covid_suspected_40-49`                         <dbl> …
## $ `previous_day_admission_adult_covid_suspected_40-49_coverage`                <dbl> …
## $ `previous_day_admission_adult_covid_suspected_50-59`                         <dbl> …
## $ `previous_day_admission_adult_covid_suspected_50-59_coverage`                <dbl> …
## $ `previous_day_admission_adult_covid_suspected_60-69`                         <dbl> …
## $ `previous_day_admission_adult_covid_suspected_60-69_coverage`                <dbl> …
## $ `previous_day_admission_adult_covid_suspected_70-79`                         <dbl> …
## $ `previous_day_admission_adult_covid_suspected_70-79_coverage`                <dbl> …
## $ `previous_day_admission_adult_covid_suspected_80+`                           <dbl> …
## $ `previous_day_admission_adult_covid_suspected_80+_coverage`                  <dbl> …
## $ previous_day_admission_adult_covid_suspected_unknown                         <dbl> …
## $ previous_day_admission_adult_covid_suspected_unknown_coverage                <dbl> …
## $ deaths_covid                                                                 <dbl> …
## $ deaths_covid_coverage                                                        <dbl> …
## $ on_hand_supply_therapeutic_a_casirivimab_imdevimab_courses                   <dbl> …
## $ on_hand_supply_therapeutic_b_bamlanivimab_courses                            <dbl> …
## $ on_hand_supply_therapeutic_c_bamlanivimab_etesevimab_courses                 <dbl> …
## $ previous_week_therapeutic_a_casirivimab_imdevimab_courses_used               <dbl> …
## $ previous_week_therapeutic_b_bamlanivimab_courses_used                        <dbl> …
## $ previous_week_therapeutic_c_bamlanivimab_etesevimab_courses_used             <dbl> …
## $ icu_patients_confirmed_influenza                                             <dbl> …
## $ icu_patients_confirmed_influenza_coverage                                    <dbl> …
## $ previous_day_admission_influenza_confirmed                                   <dbl> …
## $ previous_day_admission_influenza_confirmed_coverage                          <dbl> …
## $ previous_day_deaths_covid_and_influenza                                      <dbl> …
## $ previous_day_deaths_covid_and_influenza_coverage                             <dbl> …
## $ previous_day_deaths_influenza                                                <dbl> …
## $ previous_day_deaths_influenza_coverage                                       <dbl> …
## $ total_patients_hospitalized_confirmed_influenza                              <dbl> …
## $ total_patients_hospitalized_confirmed_influenza_and_covid                    <dbl> …
## $ total_patients_hospitalized_confirmed_influenza_and_covid_coverage           <dbl> …
## $ total_patients_hospitalized_confirmed_influenza_coverage                     <dbl> …
## $ all_pediatric_inpatient_bed_occupied                                         <dbl> …
## $ all_pediatric_inpatient_bed_occupied_coverage                                <dbl> …
## $ all_pediatric_inpatient_beds                                                 <dbl> …
## $ all_pediatric_inpatient_beds_coverage                                        <dbl> …
## $ previous_day_admission_pediatric_covid_confirmed_0_4                         <dbl> …
## $ previous_day_admission_pediatric_covid_confirmed_0_4_coverage                <dbl> …
## $ previous_day_admission_pediatric_covid_confirmed_12_17                       <dbl> …
## $ previous_day_admission_pediatric_covid_confirmed_12_17_coverage              <dbl> …
## $ previous_day_admission_pediatric_covid_confirmed_5_11                        <dbl> …
## $ previous_day_admission_pediatric_covid_confirmed_5_11_coverage               <dbl> …
## $ previous_day_admission_pediatric_covid_confirmed_unknown                     <dbl> …
## $ previous_day_admission_pediatric_covid_confirmed_unknown_coverage            <dbl> …
## $ staffed_icu_pediatric_patients_confirmed_covid                               <dbl> …
## $ staffed_icu_pediatric_patients_confirmed_covid_coverage                      <dbl> …
## $ staffed_pediatric_icu_bed_occupancy                                          <dbl> …
## $ staffed_pediatric_icu_bed_occupancy_coverage                                 <dbl> …
## $ total_staffed_pediatric_icu_beds                                             <dbl> …
## $ total_staffed_pediatric_icu_beds_coverage                                    <dbl> …
## Warning: One or more parsing issues, see `problems()` for details
## Rows: 36696 Columns: 101
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr  (2): Date, Location
## dbl (94): MMWR_week, Distributed, Distributed_Janssen, Distributed_Moderna, ...
## lgl  (5): Administered_Bivalent, Admin_Bivalent_PFR, Admin_Bivalent_MOD, Dis...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.

## 
## *** File has been checked for uniqueness by: state date

## 
## 
## Checking for similarity of: column names
## In reference but not in current: 
## In current but not in reference: 
## 
## Checking for similarity of: date
## In reference but not in current: 0
## In current but not in reference: 4
## 
## Checking for similarity of: state
## In reference but not in current: 
## In current but not in reference:

## 
## 
## ***Differences of at least 1 and at least 1%
## 
## [1] date     name     newValue refValue absDelta pctDelta
## <0 rows> (or 0-length row.names)
## 
## 
## ***Differences of at least 0 and at least 0.1%
## 
## [1] state    name     newValue refValue absDelta pctDelta
## <0 rows> (or 0-length row.names)
## 
## 
## 
## Raw file for vax:
## Rows: 36,696
## Columns: 101
## $ date                                   <date> 2022-10-26, 2022-10-26, 2022-1…
## $ MMWR_week                              <dbl> 43, 43, 43, 43, 43, 43, 43, 43,…
## $ state                                  <chr> "CO", "BP2", "DD2", "AR", "LA",…
## $ Distributed                            <dbl> 15839015, 389930, 7382310, 7633…
## $ Distributed_Janssen                    <dbl> 500100, 16200, 210700, 262300, …
## $ Distributed_Moderna                    <dbl> 5607840, 171620, 2394540, 31571…
## $ Distributed_Pfizer                     <dbl> 9713375, 202110, 4748270, 41899…
## $ Distributed_Novavax                    <dbl> 17700, 0, 28800, 23800, 6600, 4…
## $ Distributed_Unk_Manuf                  <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0…
## $ Dist_Per_100K                          <dbl> 275043, 0, 0, 252938, 206691, 2…
## $ Distributed_Per_100k_5Plus             <dbl> 291881, 0, 0, 269787, 221024, 2…
## $ Distributed_Per_100k_12Plus            <dbl> 320884, 0, 0, 298492, 244911, 2…
## $ Distributed_Per_100k_18Plus            <dbl> 352039, 0, 0, 329350, 269818, 2…
## $ Distributed_Per_100k_65Plus            <dbl> 1880200, 0, 0, 1457040, 1296680…
## $ vxa                                    <dbl> 12152626, 335497, 9079453, 4641…
## $ Administered_5Plus                     <dbl> 12068391, 335495, 9063024, 4627…
## $ Administered_12Plus                    <dbl> 11620758, 335495, 8883529, 4499…
## $ Administered_18Plus                    <dbl> 10883886, 335495, 8387809, 4225…
## $ Administered_65Plus                    <dbl> 2933378, 11277, 857771, 1405163…
## $ Administered_Janssen                   <dbl> 345410, 14176, 327958, 125793, …
## $ Administered_Moderna                   <dbl> 4622790, 154826, 2958844, 19766…
## $ Administered_Pfizer                    <dbl> 7165826, 166463, 5744807, 25343…
## $ Administered_Novavax                   <dbl> 1712, 0, 2484, 268, 480, 295, 2…
## $ Administered_Unk_Manuf                 <dbl> 16888, 32, 45360, 4366, 3639, 5…
## $ Admin_Per_100k                         <dbl> 211029, 0, 0, 153800, 144276, 1…
## $ Admin_Per_100k_5Plus                   <dbl> 222396, 0, 0, 163556, 154002, 1…
## $ Admin_Per_100k_12Plus                  <dbl> 235426, 0, 0, 175954, 167022, 1…
## $ Admin_Per_100k_18Plus                  <dbl> 241906, 0, 0, 182340, 174300, 2…
## $ Admin_Per_100k_65Plus                  <dbl> 348212, 0, 0, 268221, 266760, 2…
## $ Recip_Administered                     <dbl> 12178883, 335497, 9079453, 4695…
## $ Administered_Dose1_Recip               <dbl> 4745768, 152116, 4600027, 20805…
## $ Administered_Dose1_Pop_Pct             <dbl> 82.4, 0.0, 0.0, 68.9, 62.4, 77.…
## $ Administered_Dose1_Recip_5Plus         <dbl> 4700168, 152114, 4589610, 20718…
## $ Administered_Dose1_Recip_5PlusPop_Pct  <dbl> 86.6, 0.0, 0.0, 73.2, 66.5, 82.…
## $ Administered_Dose1_Recip_12Plus        <dbl> 4480951, 152114, 4486081, 20017…
## $ Administered_Dose1_Recip_12PlusPop_Pct <dbl> 90.8, 0.0, 0.0, 78.3, 71.7, 88.…
## $ Administered_Dose1_Recip_18Plus        <dbl> 4155669, 152114, 4230192, 18630…
## $ Administered_Dose1_Recip_18PlusPop_Pct <dbl> 92.4, 0.0, 0.0, 80.4, 74.0, 90.…
## $ Administered_Dose1_Recip_65Plus        <dbl> 890491, 4115, 476135, 515480, 6…
## $ Administered_Dose1_Recip_65PlusPop_Pct <dbl> 95.0, 0.0, 0.0, 95.0, 92.3, 95.…
## $ vxc                                    <dbl> 4175718, 138953, 3655064, 16955…
## $ vxcpoppct                              <dbl> 72.5, 0.0, 0.0, 56.2, 54.7, 62.…
## $ Series_Complete_5Plus                  <dbl> 4156753, 138952, 3652831, 16926…
## $ Series_Complete_5PlusPop_Pct           <dbl> 76.6, 0.0, 0.0, 59.8, 58.4, 66.…
## $ Series_Complete_12Plus                 <dbl> 3972620, 138952, 3583964, 16411…
## $ Series_Complete_12PlusPop_Pct          <dbl> 80.5, 0.0, 0.0, 64.2, 63.2, 71.…
## $ vxcgte18                               <dbl> 3681706, 138952, 3383916, 15285…
## $ vxcgte18pct                            <dbl> 81.8, 0.0, 0.0, 66.0, 65.6, 73.…
## $ vxcgte65                               <dbl> 808256, 3763, 251475, 435109, 6…
## $ vxcgte65pct                            <dbl> 95.0, 0.0, 0.0, 83.1, 86.9, 87.…
## $ Series_Complete_Janssen                <dbl> 316583, 13495, 319863, 115591, …
## $ Series_Complete_Moderna                <dbl> 1482213, 56214, 1106217, 684277…
## $ Series_Complete_Pfizer                 <dbl> 2364703, 69244, 2216621, 893449…
## $ Series_Complete_Novavax                <dbl> 593, 0, 931, 150, 147, 104, 130…
## $ Series_Complete_Unk_Manuf              <dbl> 4720, 0, 10757, 1304, 1348, 186…
## $ Series_Complete_Janssen_5Plus          <dbl> 316563, 13494, 319842, 115470, …
## $ Series_Complete_Moderna_5Plus          <dbl> 1470443, 56214, 1104733, 683178…
## $ Series_Complete_Pfizer_5Plus           <dbl> 2364457, 69244, 2216589, 892657…
## $ Series_Complete_Unk_Manuf_5Plus        <dbl> 4699, 0, 10736, 1295, 1343, 186…
## $ Series_Complete_Janssen_12Plus         <dbl> 316553, 13494, 319830, 115462, …
## $ Series_Complete_Moderna_12Plus         <dbl> 1469786, 56214, 1104614, 682949…
## $ Series_Complete_Pfizer_12Plus          <dbl> 2181121, 69244, 2148140, 841426…
## $ Series_Complete_Unk_Manuf_12Plus       <dbl> 4569, 0, 10450, 1248, 1306, 183…
## $ Series_Complete_Janssen_18Plus         <dbl> 316207, 13494, 319494, 115013, …
## $ Series_Complete_Moderna_18Plus         <dbl> 1469043, 56214, 1103520, 681652…
## $ Series_Complete_Pfizer_18Plus          <dbl> 1892075, 69244, 1950664, 730710…
## $ Series_Complete_Unk_Manuf_18Plus       <dbl> 3801, 0, 9316, 1173, 1259, 176,…
## $ Series_Complete_Janssen_65Plus         <dbl> 29249, 196, 10615, 15940, 22522…
## $ Series_Complete_Moderna_65Plus         <dbl> 383852, 1826, 84801, 243252, 30…
## $ Series_Complete_Pfizer_65Plus          <dbl> 393887, 1741, 155484, 175349, 3…
## $ Series_Complete_Unk_Manuf_65Plus       <dbl> 1189, 0, 563, 564, 219, 63, 878…
## $ Additional_Doses                       <dbl> 2342627, 52153, 966851, 730243,…
## $ Additional_Doses_Vax_Pct               <dbl> 56.1, 37.5, 26.5, 43.1, 42.3, 4…
## $ Additional_Doses_5Plus                 <dbl> 2342527, 52153, 966774, 730158,…
## $ Additional_Doses_5Plus_Vax_Pct         <dbl> 56.4, 37.5, 26.5, 43.1, 42.3, 4…
## $ Additional_Doses_12Plus                <dbl> 2300475, 52153, 959937, 723815,…
## $ Additional_Doses_12Plus_Vax_Pct        <dbl> 57.9, 37.5, 26.8, 44.1, 43.1, 4…
## $ Additional_Doses_18Plus                <dbl> 2188216, 52153, 921716, 700345,…
## $ Additional_Doses_18Plus_Vax_Pct        <dbl> 59.4, 37.5, 27.2, 45.8, 44.8, 4…
## $ Additional_Doses_50Plus                <dbl> 1227186, 16410, 283327, 492070,…
## $ Additional_Doses_50Plus_Vax_Pct        <dbl> 72.5, 54.6, 38.0, 58.5, 58.2, 5…
## $ Additional_Doses_65Plus                <dbl> 645598, 2658, 100062, 298265, 4…
## $ Additional_Doses_65Plus_Vax_Pct        <dbl> 79.9, 70.6, 39.8, 68.5, 68.3, 6…
## $ Additional_Doses_Moderna               <dbl> 989679, 31561, 327343, 345696, …
## $ Additional_Doses_Pfizer                <dbl> 1323953, 19927, 628820, 373658,…
## $ Additional_Doses_Janssen               <dbl> 27100, 643, 6220, 10264, 13964,…
## $ Additional_Doses_Unk_Manuf             <dbl> 1855, 22, 4183, 611, 260, 55, 3…
## $ Second_Booster                         <dbl> NA, NA, NA, NA, NA, NA, NA, NA,…
## $ Second_Booster_50Plus                  <dbl> 652497, 3571, 74708, 190165, 24…
## $ Second_Booster_50Plus_Vax_Pct          <dbl> 53.2, 21.8, 26.4, 38.6, 32.1, 3…
## $ Second_Booster_65Plus                  <dbl> 400749, 866, 33346, 135359, 166…
## $ Second_Booster_65Plus_Vax_Pct          <dbl> 62.1, 32.6, 33.3, 45.4, 37.9, 4…
## $ Second_Booster_Janssen                 <dbl> 421, 3, 94, 116, 168, 53, 313, …
## $ Second_Booster_Moderna                 <dbl> 325593, 2532, 30870, 104368, 11…
## $ Second_Booster_Pfizer                  <dbl> 493405, 2152, 74296, 108959, 15…
## $ Second_Booster_Unk_Manuf               <dbl> 742, 2, 595, 149, 38, 17, 67, 0…
## $ Administered_Bivalent                  <lgl> NA, NA, NA, NA, NA, NA, NA, NA,…
## $ Admin_Bivalent_PFR                     <lgl> NA, NA, NA, NA, NA, NA, NA, NA,…
## $ Admin_Bivalent_MOD                     <lgl> NA, NA, NA, NA, NA, NA, NA, NA,…
## $ Dist_Bivalent_PFR                      <lgl> NA, NA, NA, NA, NA, NA, NA, NA,…
## $ Dist_Bivalent_MOD                      <lgl> NA, NA, NA, NA, NA, NA, NA, NA,…
## 
## Column sums before and after applying filtering rules:
## # A tibble: 3 × 6
##   isType tot_cases tot_deaths     new_cases    new_deaths         n
##   <chr>      <dbl>      <dbl>         <dbl>         <dbl>     <dbl>
## 1 before  3.95e+10    5.62e+8 96180659      1042962       59059    
## 2 after   3.92e+10    5.59e+8 95065282      1037080       51051    
## 3 pctchg  7.28e- 3    4.64e-3        0.0116       0.00564     0.136
## 
## 
## Processed for cdcDaily:
## Rows: 51,051
## Columns: 6
## $ date       <date> 2021-03-11, 2021-12-01, 2021-11-22, 2022-05-30, 2020-04-03…
## $ state      <chr> "KS", "ND", "AL", "AK", "ND", "NM", "UT", "SD", "OH", "OK",…
## $ tot_cases  <dbl> 297229, 163565, 841461, 251425, 173, 602931, 636992, 122688…
## $ tot_deaths <dbl> 4851, 1907, 16377, 1252, 3, 8318, 3787, 1967, 18646, 471, 1…
## $ new_cases  <dbl> 0, 589, 703, 0, 14, 1509, 0, 28, 2293, 1040, 133, 133, 1028…
## $ new_deaths <dbl> 0, 9, 7, 0, 0, 6, 0, 0, 0, 4, 0, 14, 8, 0, 73, 3, 0, 0, 7, …
## 
## Column sums before and after applying filtering rules:
## # A tibble: 3 × 5
##   isType     inp hosp_adult     hosp_ped          n
##   <chr>    <dbl>      <dbl>        <dbl>      <dbl>
## 1 before 5.27e+7    4.60e+7 1311468      52391     
## 2 after  5.25e+7    4.58e+7 1285571      50037     
## 3 pctchg 5.43e-3    5.19e-3       0.0197     0.0449
## 
## 
## Processed for cdcHosp:
## Rows: 50,037
## Columns: 5
## $ date       <date> 2021-01-26, 2021-01-23, 2021-01-21, 2021-01-13, 2021-01-10…
## $ state      <chr> "OK", "MN", "RI", "OR", "RI", "KS", "SC", "RI", "RI", "LA",…
## $ inp        <dbl> 1598, 618, 407, 512, 449, 989, 2246, 461, 483, 1619, 471, 7…
## $ hosp_adult <dbl> 1516, 598, 399, 507, 446, 986, 2232, 456, 479, 1609, 469, 7…
## $ hosp_ped   <dbl> 82, 20, 8, 5, 3, 3, 14, 5, 4, 10, 2, 81, 16, 1, 9, 22, 1, 0…
## 
## Column sums before and after applying filtering rules:
## # A tibble: 3 × 9
##   isType      vxa      vxc   vxcpoppct vxcgte65 vxcgt…¹ vxcgte18 vxcgt…²       n
##   <chr>     <dbl>    <dbl>       <dbl>    <dbl>   <dbl>    <dbl>   <dbl>   <dbl>
## 1 before 4.24e+11 1.74e+11 1544457.    4.40e+10 2.28e+6 1.61e+11 1.82e+6 3.67e+4
## 2 after  2.04e+11 8.40e+10 1292563.    2.13e+10 2.02e+6 7.77e+10 1.54e+6 2.90e+4
## 3 pctchg 5.18e- 1 5.16e- 1       0.163 5.16e- 1 1.15e-1 5.16e- 1 1.54e-1 2.09e-1
## # … with abbreviated variable names ¹​vxcgte65pct, ²​vxcgte18pct
## 
## 
## Processed for vax:
## Rows: 29,019
## Columns: 9
## $ date        <date> 2022-10-26, 2022-10-26, 2022-10-26, 2022-10-26, 2022-10-2…
## $ state       <chr> "CO", "AR", "LA", "NV", "KY", "MN", "AL", "OH", "MT", "WV"…
## $ vxa         <dbl> 12152626, 4641392, 6707088, 5315414, 7144109, 11838868, 66…
## $ vxc         <dbl> 4175718, 1695580, 2541814, 1930260, 2634385, 4013235, 2576…
## $ vxcpoppct   <dbl> 72.5, 56.2, 54.7, 62.7, 59.0, 71.2, 52.5, 59.8, 58.4, 59.2…
## $ vxcgte65    <dbl> 808256, 435109, 644253, 434579, 663968, 908701, 714593, 18…
## $ vxcgte65pct <dbl> 95.0, 83.1, 86.9, 87.6, 88.5, 95.0, 84.1, 88.9, 88.3, 86.8…
## $ vxcgte18    <dbl> 3681706, 1528584, 2334821, 1747560, 2393411, 3494198, 2386…
## $ vxcgte18pct <dbl> 81.8, 66.0, 65.6, 73.2, 69.1, 80.6, 62.6, 69.2, 67.6, 68.4…
## 
## Integrated per capita data file:
## Rows: 51,927
## Columns: 34
## $ date        <date> 2020-01-01, 2020-01-01, 2020-01-01, 2020-01-01, 2020-01-0…
## $ state       <chr> "AL", "HI", "IN", "LA", "MN", "MT", "NC", "TX", "AL", "HI"…
## $ tot_cases   <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ tot_deaths  <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ new_cases   <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ new_deaths  <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ inp         <dbl> NA, 0, 0, NA, 0, 0, 0, 0, NA, 0, 0, NA, 0, 0, 0, 1877, 0, …
## $ hosp_adult  <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ hosp_ped    <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ vxa         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ vxc         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ vxcpoppct   <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ vxcgte65    <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ vxcgte65pct <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ vxcgte18    <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ vxcgte18pct <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ tcpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ tdpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ cpm         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ dpm         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ hpm         <dbl> NA, 0.0000, 0.0000, NA, 0.0000, 0.0000, 0.0000, 0.0000, NA…
## $ ahpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ phpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ vxapm       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ vxcpm       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ tcpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ tdpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ cpm7        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ dpm7        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ hpm7        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ ahpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ phpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ vxapm7      <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ vxcpm7      <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj =
## prefer_proj): Discarded datum unknown in Proj4 definition

saveToRDS(cdc_daily_221102, ovrWriteError=FALSE)

The CDC modified deaths and cases reporting to be weekly, based on summation of county-level data to states. Per their website, methodology has changed (inconsistency between datasets?) and the previous daily data is no longer updated as of October 20, 2022. Weekly deaths and cases data are available at CDC website

The latest hospitalization data is also downloaded and processed:

# Run for latest data, save as RDS
indivHosp_20221103 <- downloadReadHospitalData(loc="./RInputFiles/Coronavirus/HHS_Hospital_20221103.csv")
## 
## File ./RInputFiles/Coronavirus/HHS_Hospital_20221103.csv already exists
## File will not be downloaded since ovrWrite is not TRUE
## Rows: 132411 Columns: 128
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr   (11): hospital_pk, state, ccn, hospital_name, address, city, zip, hosp...
## dbl  (114): total_beds_7_day_avg, all_adult_hospital_beds_7_day_avg, all_adu...
## lgl    (2): is_metro_micro, is_corrected
## date   (1): collection_week
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
## Rows: 132,411
## Columns: 128
## $ hospital_pk                                                                        <chr> …
## $ collection_week                                                                    <date> …
## $ state                                                                              <chr> …
## $ ccn                                                                                <chr> …
## $ hospital_name                                                                      <chr> …
## $ address                                                                            <chr> …
## $ city                                                                               <chr> …
## $ zip                                                                                <chr> …
## $ hospital_subtype                                                                   <chr> …
## $ fips_code                                                                          <chr> …
## $ is_metro_micro                                                                     <lgl> …
## $ total_beds_7_day_avg                                                               <dbl> …
## $ all_adult_hospital_beds_7_day_avg                                                  <dbl> …
## $ all_adult_hospital_inpatient_beds_7_day_avg                                        <dbl> …
## $ inpatient_beds_used_7_day_avg                                                      <dbl> …
## $ all_adult_hospital_inpatient_bed_occupied_7_day_avg                                <dbl> …
## $ inpatient_beds_used_covid_7_day_avg                                                <dbl> …
## $ total_adult_patients_hospitalized_confirmed_and_suspected_covid_7_day_avg          <dbl> …
## $ total_adult_patients_hospitalized_confirmed_covid_7_day_avg                        <dbl> …
## $ total_pediatric_patients_hospitalized_confirmed_and_suspected_covid_7_day_avg      <dbl> …
## $ total_pediatric_patients_hospitalized_confirmed_covid_7_day_avg                    <dbl> …
## $ inpatient_beds_7_day_avg                                                           <dbl> …
## $ total_icu_beds_7_day_avg                                                           <dbl> …
## $ total_staffed_adult_icu_beds_7_day_avg                                             <dbl> …
## $ icu_beds_used_7_day_avg                                                            <dbl> …
## $ staffed_adult_icu_bed_occupancy_7_day_avg                                          <dbl> …
## $ staffed_icu_adult_patients_confirmed_and_suspected_covid_7_day_avg                 <dbl> …
## $ staffed_icu_adult_patients_confirmed_covid_7_day_avg                               <dbl> …
## $ total_patients_hospitalized_confirmed_influenza_7_day_avg                          <dbl> …
## $ icu_patients_confirmed_influenza_7_day_avg                                         <dbl> …
## $ total_patients_hospitalized_confirmed_influenza_and_covid_7_day_avg                <dbl> …
## $ total_beds_7_day_sum                                                               <dbl> …
## $ all_adult_hospital_beds_7_day_sum                                                  <dbl> …
## $ all_adult_hospital_inpatient_beds_7_day_sum                                        <dbl> …
## $ inpatient_beds_used_7_day_sum                                                      <dbl> …
## $ all_adult_hospital_inpatient_bed_occupied_7_day_sum                                <dbl> …
## $ inpatient_beds_used_covid_7_day_sum                                                <dbl> …
## $ total_adult_patients_hospitalized_confirmed_and_suspected_covid_7_day_sum          <dbl> …
## $ total_adult_patients_hospitalized_confirmed_covid_7_day_sum                        <dbl> …
## $ total_pediatric_patients_hospitalized_confirmed_and_suspected_covid_7_day_sum      <dbl> …
## $ total_pediatric_patients_hospitalized_confirmed_covid_7_day_sum                    <dbl> …
## $ inpatient_beds_7_day_sum                                                           <dbl> …
## $ total_icu_beds_7_day_sum                                                           <dbl> …
## $ total_staffed_adult_icu_beds_7_day_sum                                             <dbl> …
## $ icu_beds_used_7_day_sum                                                            <dbl> …
## $ staffed_adult_icu_bed_occupancy_7_day_sum                                          <dbl> …
## $ staffed_icu_adult_patients_confirmed_and_suspected_covid_7_day_sum                 <dbl> …
## $ staffed_icu_adult_patients_confirmed_covid_7_day_sum                               <dbl> …
## $ total_patients_hospitalized_confirmed_influenza_7_day_sum                          <dbl> …
## $ icu_patients_confirmed_influenza_7_day_sum                                         <dbl> …
## $ total_patients_hospitalized_confirmed_influenza_and_covid_7_day_sum                <dbl> …
## $ total_beds_7_day_coverage                                                          <dbl> …
## $ all_adult_hospital_beds_7_day_coverage                                             <dbl> …
## $ all_adult_hospital_inpatient_beds_7_day_coverage                                   <dbl> …
## $ inpatient_beds_used_7_day_coverage                                                 <dbl> …
## $ all_adult_hospital_inpatient_bed_occupied_7_day_coverage                           <dbl> …
## $ inpatient_beds_used_covid_7_day_coverage                                           <dbl> …
## $ total_adult_patients_hospitalized_confirmed_and_suspected_covid_7_day_coverage     <dbl> …
## $ total_adult_patients_hospitalized_confirmed_covid_7_day_coverage                   <dbl> …
## $ total_pediatric_patients_hospitalized_confirmed_and_suspected_covid_7_day_coverage <dbl> …
## $ total_pediatric_patients_hospitalized_confirmed_covid_7_day_coverage               <dbl> …
## $ inpatient_beds_7_day_coverage                                                      <dbl> …
## $ total_icu_beds_7_day_coverage                                                      <dbl> …
## $ total_staffed_adult_icu_beds_7_day_coverage                                        <dbl> …
## $ icu_beds_used_7_day_coverage                                                       <dbl> …
## $ staffed_adult_icu_bed_occupancy_7_day_coverage                                     <dbl> …
## $ staffed_icu_adult_patients_confirmed_and_suspected_covid_7_day_coverage            <dbl> …
## $ staffed_icu_adult_patients_confirmed_covid_7_day_coverage                          <dbl> …
## $ total_patients_hospitalized_confirmed_influenza_7_day_coverage                     <dbl> …
## $ icu_patients_confirmed_influenza_7_day_coverage                                    <dbl> …
## $ total_patients_hospitalized_confirmed_influenza_and_covid_7_day_coverage           <dbl> …
## $ previous_day_admission_adult_covid_confirmed_7_day_sum                             <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_18-19_7_day_sum`                     <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_20-29_7_day_sum`                     <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_30-39_7_day_sum`                     <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_40-49_7_day_sum`                     <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_50-59_7_day_sum`                     <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_60-69_7_day_sum`                     <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_70-79_7_day_sum`                     <dbl> …
## $ `previous_day_admission_adult_covid_confirmed_80+_7_day_sum`                       <dbl> …
## $ previous_day_admission_adult_covid_confirmed_unknown_7_day_sum                     <dbl> …
## $ previous_day_admission_pediatric_covid_confirmed_7_day_sum                         <dbl> …
## $ previous_day_covid_ED_visits_7_day_sum                                             <dbl> …
## $ previous_day_admission_adult_covid_suspected_7_day_sum                             <dbl> …
## $ `previous_day_admission_adult_covid_suspected_18-19_7_day_sum`                     <dbl> …
## $ `previous_day_admission_adult_covid_suspected_20-29_7_day_sum`                     <dbl> …
## $ `previous_day_admission_adult_covid_suspected_30-39_7_day_sum`                     <dbl> …
## $ `previous_day_admission_adult_covid_suspected_40-49_7_day_sum`                     <dbl> …
## $ `previous_day_admission_adult_covid_suspected_50-59_7_day_sum`                     <dbl> …
## $ `previous_day_admission_adult_covid_suspected_60-69_7_day_sum`                     <dbl> …
## $ `previous_day_admission_adult_covid_suspected_70-79_7_day_sum`                     <dbl> …
## $ `previous_day_admission_adult_covid_suspected_80+_7_day_sum`                       <dbl> …
## $ previous_day_admission_adult_covid_suspected_unknown_7_day_sum                     <dbl> …
## $ previous_day_admission_pediatric_covid_suspected_7_day_sum                         <dbl> …
## $ previous_day_total_ED_visits_7_day_sum                                             <dbl> …
## $ previous_day_admission_influenza_confirmed_7_day_sum                               <dbl> …
## $ geocoded_hospital_address                                                          <chr> …
## $ hhs_ids                                                                            <chr> …
## $ previous_day_admission_adult_covid_confirmed_7_day_coverage                        <dbl> …
## $ previous_day_admission_pediatric_covid_confirmed_7_day_coverage                    <dbl> …
## $ previous_day_admission_adult_covid_suspected_7_day_coverage                        <dbl> …
## $ previous_day_admission_pediatric_covid_suspected_7_day_coverage                    <dbl> …
## $ previous_week_personnel_covid_vaccinated_doses_administered_7_day                  <dbl> …
## $ total_personnel_covid_vaccinated_doses_none_7_day                                  <dbl> …
## $ total_personnel_covid_vaccinated_doses_one_7_day                                   <dbl> …
## $ total_personnel_covid_vaccinated_doses_all_7_day                                   <dbl> …
## $ previous_week_patients_covid_vaccinated_doses_one_7_day                            <dbl> …
## $ previous_week_patients_covid_vaccinated_doses_all_7_day                            <dbl> …
## $ is_corrected                                                                       <lgl> …
## $ all_pediatric_inpatient_bed_occupied_7_day_avg                                     <dbl> …
## $ all_pediatric_inpatient_bed_occupied_7_day_coverage                                <dbl> …
## $ all_pediatric_inpatient_bed_occupied_7_day_sum                                     <dbl> …
## $ all_pediatric_inpatient_beds_7_day_avg                                             <dbl> …
## $ all_pediatric_inpatient_beds_7_day_coverage                                        <dbl> …
## $ all_pediatric_inpatient_beds_7_day_sum                                             <dbl> …
## $ previous_day_admission_pediatric_covid_confirmed_0_4_7_day_sum                     <dbl> …
## $ previous_day_admission_pediatric_covid_confirmed_12_17_7_day_sum                   <dbl> …
## $ previous_day_admission_pediatric_covid_confirmed_5_11_7_day_sum                    <dbl> …
## $ previous_day_admission_pediatric_covid_confirmed_unknown_7_day_sum                 <dbl> …
## $ staffed_icu_pediatric_patients_confirmed_covid_7_day_avg                           <dbl> …
## $ staffed_icu_pediatric_patients_confirmed_covid_7_day_coverage                      <dbl> …
## $ staffed_icu_pediatric_patients_confirmed_covid_7_day_sum                           <dbl> …
## $ staffed_pediatric_icu_bed_occupancy_7_day_avg                                      <dbl> …
## $ staffed_pediatric_icu_bed_occupancy_7_day_coverage                                 <dbl> …
## $ staffed_pediatric_icu_bed_occupancy_7_day_sum                                      <dbl> …
## $ total_staffed_pediatric_icu_beds_7_day_avg                                         <dbl> …
## $ total_staffed_pediatric_icu_beds_7_day_coverage                                    <dbl> …
## $ total_staffed_pediatric_icu_beds_7_day_sum                                         <dbl> …
## 
## Hospital Subtype Counts:
## # A tibble: 4 × 2
##   hospital_subtype              n
##   <chr>                     <int>
## 1 Childrens Hospitals        2472
## 2 Critical Access Hospitals 35614
## 3 Long Term                  8968
## 4 Short Term                85357
## 
## Records other than 50 states and DC
## # A tibble: 5 × 2
##   state     n
##   <chr> <int>
## 1 AS       12
## 2 GU       68
## 3 MP       25
## 4 PR     1311
## 5 VI       54
## 
## Record types for key metrics
## # A tibble: 10 × 5
##    name                                              `NA` Posit…¹ Value…²  Total
##    <chr>                                            <int>   <int>   <int>  <int>
##  1 all_adult_hospital_beds_7_day_avg                36802   95379     230 132411
##  2 all_adult_hospital_inpatient_bed_occupied_7_day… 20208  102724    9479 132411
##  3 icu_beds_used_7_day_avg                          22029   96812   13570 132411
##  4 inpatient_beds_7_day_avg                          5519  126362     530 132411
##  5 inpatient_beds_used_7_day_avg                     5519  116077   10815 132411
##  6 inpatient_beds_used_covid_7_day_avg               1253   88897   42261 132411
##  7 staffed_icu_adult_patients_confirmed_and_suspec… 20215   77013   35183 132411
##  8 total_adult_patients_hospitalized_confirmed_and… 18629   77473   36309 132411
##  9 total_beds_7_day_avg                             20916  111369     126 132411
## 10 total_icu_beds_7_day_avg                          2231  123464    6716 132411
## # … with abbreviated variable names ¹​Positive, ²​`Value -999999`
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

saveToRDS(indivHosp_20221103, ovrWriteError=FALSE)

Post-processing is run, including hospital summaries:

# Create pivoted burden data
burdenPivotList_221102 <- postProcessCDCDaily(cdc_daily_221102, 
                                              dataThruLabel="Oct 2022", 
                                              keyDatesBurden=c("2022-10-15", "2022-04-15", 
                                                               "2021-10-15", "2021-04-15"
                                                               ),
                                              keyDatesVaccine=c("2022-10-26", "2022-04-30", 
                                                                "2021-10-31", "2021-04-30"
                                                                ), 
                                              returnData=TRUE
                                              )
## Joining, by = "state"
## 
## *** File has been checked for uniqueness by: state date name
## Warning: Removed 24 row(s) containing missing values (geom_path).

## Warning: Removed 24 rows containing missing values (position_stack).

## Warning: Removed 24 rows containing missing values (position_stack).

## Warning: Removed 9 row(s) containing missing values (geom_path).

# Create hospitalized per capita data
hospPerCap_221102 <- hospAgePerCapita(readFromRDS("dfStateAgeBucket2019"), 
                                      lst=burdenPivotList_221102, 
                                      popVar="pop2019", 
                                      excludeState=c(), 
                                      cumStartDate="2020-07-15"
                                      )
## Warning: Removed 18 row(s) containing missing values (geom_path).

burdenPivotList_221102$hospAge %>%
    group_by(adultPed, confSusp, age, name) %>%
    summarize(value=sum(value, na.rm=TRUE), n=n(), .groups="drop")
## # A tibble: 18 × 6
##    adultPed confSusp  age   name                                     value     n
##    <chr>    <chr>     <chr> <chr>                                    <dbl> <int>
##  1 adult    confirmed 0-19  previous_day_admission_adult_covid_con… 4.83e4 52391
##  2 adult    confirmed 20-29 previous_day_admission_adult_covid_con… 2.95e5 52391
##  3 adult    confirmed 30-39 previous_day_admission_adult_covid_con… 4.25e5 52391
##  4 adult    confirmed 40-49 previous_day_admission_adult_covid_con… 5.07e5 52391
##  5 adult    confirmed 50-59 previous_day_admission_adult_covid_con… 8.11e5 52391
##  6 adult    confirmed 60-69 previous_day_admission_adult_covid_con… 1.07e6 52391
##  7 adult    confirmed 70-79 previous_day_admission_adult_covid_con… 1.09e6 52391
##  8 adult    confirmed 80+   previous_day_admission_adult_covid_con… 9.88e5 52391
##  9 adult    suspected 0-19  previous_day_admission_adult_covid_sus… 4.00e4 52391
## 10 adult    suspected 20-29 previous_day_admission_adult_covid_sus… 2.67e5 52391
## 11 adult    suspected 30-39 previous_day_admission_adult_covid_sus… 3.51e5 52391
## 12 adult    suspected 40-49 previous_day_admission_adult_covid_sus… 3.55e5 52391
## 13 adult    suspected 50-59 previous_day_admission_adult_covid_sus… 5.61e5 52391
## 14 adult    suspected 60-69 previous_day_admission_adult_covid_sus… 7.75e5 52391
## 15 adult    suspected 70-79 previous_day_admission_adult_covid_sus… 7.57e5 52391
## 16 adult    suspected 80+   previous_day_admission_adult_covid_sus… 6.90e5 52391
## 17 ped      confirmed 0-19  previous_day_admission_pediatric_covid… 1.77e5 52391
## 18 ped      suspected 0-19  previous_day_admission_pediatric_covid… 4.04e5 52391
saveToRDS(burdenPivotList_221102, ovrWriteError=FALSE)
saveToRDS(hospPerCap_221102, ovrWriteError=FALSE)

Peaks and valleys of key metrics are also updated:

peakValleyCDCDaily(cdc_daily_221102)
## Warning: Removed 6 row(s) containing missing values (geom_path).

## Warning: Removed 6 row(s) containing missing values (geom_path).

## Warning: Removed 6 row(s) containing missing values (geom_path).

## Warning: Removed 20 row(s) containing missing values (geom_path).

## Warning: Removed 20 row(s) containing missing values (geom_path).

## # A tibble: 8,412 × 8
##    date       state   vxa   vxc vxa_isPeak vxc_isPeak vxa_isValley vxc_isValley
##    <date>     <chr> <dbl> <dbl> <lgl>      <lgl>      <lgl>        <lgl>       
##  1 2020-12-01 CA       NA    NA FALSE      FALSE      FALSE        FALSE       
##  2 2020-12-01 FL       NA    NA FALSE      FALSE      FALSE        FALSE       
##  3 2020-12-01 GA       NA    NA FALSE      FALSE      FALSE        FALSE       
##  4 2020-12-01 IL       NA    NA FALSE      FALSE      FALSE        FALSE       
##  5 2020-12-01 MI       NA    NA FALSE      FALSE      FALSE        FALSE       
##  6 2020-12-01 NC       NA    NA FALSE      FALSE      FALSE        FALSE       
##  7 2020-12-01 NJ       NA    NA FALSE      FALSE      FALSE        FALSE       
##  8 2020-12-01 NY       NA    NA FALSE      FALSE      FALSE        FALSE       
##  9 2020-12-01 OH       NA    NA FALSE      FALSE      FALSE        FALSE       
## 10 2020-12-01 PA       NA    NA FALSE      FALSE      FALSE        FALSE       
## # … with 8,402 more rows
## # ℹ Use `print(n = ...)` to see more rows

Hospital data are pieced together as needed:

# Create modified hospital data
multiSourceHosp_20221102 <- multiSourceDataCombine(list(readFromRDS("indivHosp_20220704"),
                                                        readFromRDS("indivHosp_20221103")
                                                        ),
                                                   timeVec=as.Date("2022-01-01")
                                                   )

The updated hospital data are then plotted:

# Run hospital plots
modStateHosp_20221102 <- hospitalCapacityCDCDaily(multiSourceHosp_20221102, 
                                                  plotSub="Aug 2020 to Oct 2022\nOld data used pre-2022"
                                                  )

An example of the new data file is downloaded manually and then read:

tmpBurden <- fileRead("./RInputFiles/Coronavirus/Weekly_United_States_COVID-19_Cases_and_Deaths_by_State.csv")
## Rows: 8820 Columns: 8
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr  (1): state
## dbl  (4): tot_cases, new_cases, tot_deaths, new_deaths
## date (3): date_updated, start_date, end_date
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
glimpse(tmpBurden)
## Rows: 8,820
## Columns: 8
## $ date_updated <date> 2020-01-23, 2020-01-30, 2020-02-06, 2020-02-13, 2020-02-…
## $ state        <chr> "AK", "AK", "AK", "AK", "AK", "AK", "AK", "AK", "AK", "AK…
## $ start_date   <date> 2020-01-16, 2020-01-23, 2020-01-30, 2020-02-06, 2020-02-…
## $ end_date     <date> 2020-01-22, 2020-01-29, 2020-02-05, 2020-02-12, 2020-02-…
## $ tot_cases    <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 11, 63, 149, 235, 300, 337, 355, …
## $ new_cases    <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 11, 52, 86, 86, 65, 37, 18, 19, 1…
## $ tot_deaths   <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 7, 9, 9, 9, 10, 10, 10, …
## $ new_deaths   <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 4, 2, 0, 0, 1, 0, 0, 0, …
# Check for states
tmpStateBurden <- tmpBurden %>%
    arrange(end_date, state) %>%
    group_by(state) %>%
    summarize(across(c(new_cases, new_deaths), .fns=sum, na.rm=TRUE), 
              across(c(tot_cases, tot_deaths), .fns=max, na.rm=TRUE)
              ) %>%
    ungroup()

# Are all 50 states and DC included?
tmpStateBurden %>%
    filter(state %in% c(state.abb, "DC")) %>%
    arrange(desc(tot_deaths)) %>%
    print(n=+Inf)
## # A tibble: 51 × 5
##    state new_cases new_deaths tot_cases tot_deaths
##    <chr>     <dbl>      <dbl>     <dbl>      <dbl>
##  1 CA     11401645      96334  11401645      96334
##  2 TX      8018724      91253   8018724      91253
##  3 FL      7215695      82535   7215695      82535
##  4 PA      3329409      47934   3329409      47934
##  5 GA      2929463      40803   2929463      40803
##  6 OH      3197300      40249   3197300      40249
##  7 IL      3832739      40083   3832739      40083
##  8 MI      2907819      39574   2907819      39574
##  9 NJ      2813645      34958   2813645      34958
## 10 AZ      2300375      31613   2300375      31613
## 11 NY      3329357      30451   3329357      30451
## 12 TN      2371639      28187   2371639      28187
## 13 NC      3255540      27267   3255540      27267
## 14 IN      1948019      25013   1948019      25013
## 15 VA      2129684      22234   2129684      22234
## 16 MA      2099238      22209   2099238      22209
## 17 MO      1684433      21938   1684433      21938
## 18 AL      1540329      20608   1540329      20608
## 19 SC      1729333      18660   1729333      18660
## 20 LA      1465700      18218   1465700      18218
## 21 KY      1619549      17363   1619549      17363
## 22 MD      1275208      15603   1275208      15603
## 23 WI      1907232      15511   1907232      15511
## 24 OK      1211210      14992   1211210      14992
## 25 WA      1843926      14653   1843926      14653
## 26 MN      1694438      13558   1694438      13558
## 27 CO      1683848      13473   1683848      13473
## 28 MS       935770      13005    935770      13005
## 29 AR       962764      12523    962764      12523
## 30 NV       857473      11580    857473      11580
## 31 CT       915786      11527    915786      11527
## 32 IA       866615      10229    866615      10229
## 33 KS       893300       9156    893300       9626
## 34 OR       913809       8743    913809       8743
## 35 NM       633631       8675    633631       8675
## 36 WV       610432       7538    610432       7538
## 37 ID       502130       5237    502130       5237
## 38 UT      1050455       5066   1050455       5066
## 39 NE       537129       4606    537129       4606
## 40 RI       413725       3705    413725       3705
## 41 MT       316251       3581    316251       3581
## 42 DE       314553       3148    314553       3148
## 43 SD       265890       3078    265890       3078
## 44 NH       358819       2782    358819       2782
## 45 ME       299321       2711    299321       2711
## 46 ND       273779       2232    273779       2232
## 47 WY       179366       1917    179366       1917
## 48 HI       351617       1685    351617       1685
## 49 DC       170482       1392    170482       1402
## 50 AK       285355       1376    285355       1376
## 51 VT       145838        763    145838        763
# What other states are included?
tmpStateBurden %>%
    filter(!(state %in% c(state.abb, "DC"))) %>%
    arrange(desc(tot_deaths)) %>%
    print(n=+Inf)
## # A tibble: 9 × 5
##   state new_cases new_deaths tot_cases tot_deaths
##   <chr>     <dbl>      <dbl>     <dbl>      <dbl>
## 1 NYC     2962479      42409   2962479      42966
## 2 PR       990366       5285    990366       5285
## 3 GU        58990        406     58990        406
## 4 VI        23435        124     23435        124
## 5 FSM       22203         58     22203         58
## 6 MP        13219         41     13219         41
## 7 AS         8257         34      8257         34
## 8 RMI       15386         17     15386         17
## 9 PW         5530          7      5530          7
# Are there disconnects between total and sum of new?
tmpStateBurden %>%
    filter((new_cases != tot_cases) | (new_deaths != tot_deaths)) %>%
    mutate(ratCase=tot_cases/new_cases, ratDeath=tot_deaths/new_deaths)
## # A tibble: 3 × 7
##   state new_cases new_deaths tot_cases tot_deaths ratCase ratDeath
##   <chr>     <dbl>      <dbl>     <dbl>      <dbl>   <dbl>    <dbl>
## 1 DC       170482       1392    170482       1402       1     1.01
## 2 KS       893300       9156    893300       9626       1     1.05
## 3 NYC     2962479      42409   2962479      42966       1     1.01

NYC data appear to be tracked separately from NY data, requiring combination. Otherwise, the expected geographical units appear to be included, and with totals and sum of new matching (exceptions for deaths in DC, NYC, and Kansas).

Similarity of total burden is compared:

tmpBurdenDate <- tmpBurden %>%
    select(date=end_date, state, where(is.numeric)) %>%
    bind_rows(cdc_daily_221102$dfProcess$cdcDaily, .id="src") %>%
    mutate(src=c("1"="CDC weekly (new)", "2"="CDC daily (old)")[src])
tmpBurdenDate
## # A tibble: 59,871 × 7
##    src              date       state tot_cases new_cases tot_deaths new_deaths
##    <chr>            <date>     <chr>     <dbl>     <dbl>      <dbl>      <dbl>
##  1 CDC weekly (new) 2020-01-22 AK            0         0          0          0
##  2 CDC weekly (new) 2020-01-29 AK            0         0          0          0
##  3 CDC weekly (new) 2020-02-05 AK            0         0          0          0
##  4 CDC weekly (new) 2020-02-12 AK            0         0          0          0
##  5 CDC weekly (new) 2020-02-19 AK            0         0          0          0
##  6 CDC weekly (new) 2020-02-26 AK            0         0          0          0
##  7 CDC weekly (new) 2020-03-04 AK            0         0          0          0
##  8 CDC weekly (new) 2020-03-11 AK            0         0          0          0
##  9 CDC weekly (new) 2020-03-18 AK           11        11          0          0
## 10 CDC weekly (new) 2020-03-25 AK           63        52          1          1
## # … with 59,861 more rows
## # ℹ Use `print(n = ...)` to see more rows
# Plot for total deaths and total cases
tmpBurdenDate %>%
    filter(state %in% c(state.abb, "DC", "NYC")) %>%
    group_by(src, date) %>%
    summarize(across(where(is.numeric), sum, na.rm=TRUE), .groups="drop") %>%
    pivot_longer(where(is.numeric)) %>%
    filter(name %in% c("tot_cases", "tot_deaths")) %>%
    ggplot(aes(x=date, y=value)) + 
    geom_line(aes(color=src, group=src)) + 
    facet_wrap(~name, scales="free_y")

# Plot by state - latest burden
tmpBurdenDate %>%
    filter(state %in% c(state.abb, "DC", "NYC")) %>%
    group_by(src, state) %>%
    summarize(across(where(is.numeric), last, order_by=date), .groups="drop") %>%
    pivot_longer(where(is.numeric)) %>%
    filter(name %in% c("tot_cases", "tot_deaths")) %>%
    ggplot(aes(x=fct_reorder(state, value), y=value)) + 
    geom_point(aes(color=src)) + 
    facet_wrap(~name, scales="free_x") + 
    coord_flip() + 
    labs(x=NULL, y=NULL, title="Most recent burden by state and data source") + 
    scale_color_discrete("Source")

# Plot by state - difference in burden
tmpBurdenDate %>%
    filter(state %in% c(state.abb, "DC", "NYC")) %>%
    group_by(src, state) %>%
    summarize(across(where(is.numeric), last, order_by=date), .groups="drop") %>%
    pivot_longer(where(is.numeric)) %>%
    filter(name %in% c("tot_cases", "tot_deaths")) %>%
    group_by(state, name) %>%
    summarize(value=sum(ifelse(src!="CDC daily (old)", value, 0)) - sum(ifelse(src=="CDC daily (old)", value, 0)), 
              .groups="drop"
              ) %>%
    ggplot(aes(x=fct_reorder(state, value), y=value)) + 
    geom_point() + 
    facet_wrap(~name, scales="free_x") + 
    coord_flip() + 
    labs(x=NULL, y=NULL, title="Change in most recent burden by state (new minus old)") + 
    geom_hline(yintercept=0, lty=2)

At a first glance, national totals are well aligned between the existing daily data file and the new weekly data file. The newer data has two weeks of extra reporting, so most recent totals by state are generally slightly higher. The new data breaks apart NYC and NY, which need to be combined for processing the new file

Function readQCRawCDCDaily() is updated:

# Function to read and check a raw data file (last updated 16-NOV-2022, previously updated 02-AUG-2021)
readQCRawCDCDaily <- function(fileName, 
                              writeLog=NULL,
                              ovrwriteLog=TRUE,
                              dfRef=NULL,
                              urlType=NULL,
                              url=NULL, 
                              getData=TRUE,
                              ovrWriteDownload=FALSE, 
                              vecRename=NULL, 
                              selfList=NULL,
                              fullList=NULL,
                              uniqueBy=NULL, 
                              step3Group=NULL,
                              step3Vals=NULL, 
                              step4KeyVars=NULL, 
                              step5PlotItems=NULL,
                              step6AggregateList=NULL,
                              inferVars=list("url"=urlMapper, 
                                             "vecRename"=renMapper, 
                                             "selfList"=selfListMapper, 
                                             "fullList"=fullListMapper, 
                                             "uniqueBy"=uqMapper, 
                                             "step3Group"=checkControlGroupMapper,
                                             "step3Vals"=checkControlVarsMapper, 
                                             "step4KeyVars"=checkSimilarityMapper, 
                                             "step5PlotItems"=plotSimilarityMapper,
                                             "step6AggregateList"=keyAggMapper
                                             )
                              ) {
    
    # FUNCTION ARGUMENTS
    # fileName: the location where downloaded data either is, or will be, stored
    # writeLog: the external file location for printing (NULL means use the main log stdout)
    # ovrwriteLog: boolean, if using an external log, should it be started from scratch (overwritten)?
    # dfRef: a reference data frame for comparison (either NULL or NA means do not run comparisons)
    # urlType: character vector that can be mapped using urlMapper and keyVarMapper
    # url: direct URL passed as character string
    #      NOTE that if both url and urlType are NULL, no file will be downloaded
    # getData: boolean, should an attempt be made to get new data using urlType or url?
    # ovrWriteDownload: boolean, if fileName already exists, should it be overwritten?
    # vecRename: vector for renaming c('existing name'='new name'), can be any length from 0 to ncol(df)
    #            NULL means infer from urlType, if not available there use c()
    # selfList: list for functions to apply to self, list('variable'=fn) will apply variable=fn(variable)
    #           processed in order, so more than one function can be applied to self
    #           NULL means infer from urlType, if not available in mapping file use list()
    # fullList: list for general functions to be applied, list('new variable'=expression(code))
    #           will create 'new variable' as eval(expression(code))
    #           for now, requires passing an expression
    #           NULL means infer from urlType, use list() if not in mapping file
    # uniqueBy: combination of variables for checking uniqueness
    #           NULL means infer from data, keep as NULL (meaning use-all) if cannot be inferred
    # step3Group: variable to be used as the x-axis (grouping) for step 3 plots
    #             NULL means infer from data
    # step3Vals: values to be plotted on the y-axis for step 3 plots
    #            NULL means infer from data
    # step4KeyVars: list of parameters to be passed as keyVars= in step 4
    #               NULL means infer from urlType
    # step5PlotItems: items to be plotted in step 5
    #                 NULL means infer from urlType
    # step6AggregateList: drives the elements to be passed to compareAggregate() and flagLargeDelta()
    #                     NULL means infer from urlType
    # inferVars: vector of c('variable'='mapper') for inferring parameter values when passed as NULL
    
    # Step 0a: Use urlType to infer key variables if passed as NULL
    for (vrbl in names(inferVars)) {
        mapper <- inferVars[[vrbl]]
        if (is.null(get(vrbl))) {
            if (urlType %in% names(mapper)) assign(vrbl, mapper[[urlType]])
            else if ("default" %in% names(mapper)) assign(vrbl, mapper[["default"]])
        }
    }
    
    # Step 1: Download a new file (if requested)
    if (!is.null(url) & isTRUE(getData)) fileDownload(fileName=fileName, url=url, ovrWrite=ovrWriteDownload)
    else cat("\nNo file has been downloaded, will use existing file:", fileName, "\n")
    
    # Step 2: Read file, rename and mutate variables, confirm uniqueness by expected levels
    dfRaw <- fileRead(fileName) %>% 
        colRenamer(vecRename) %>% 
        colMutater(selfList=selfList, fullList=fullList) %>%
        checkUniqueRows(uniqueBy=uniqueBy)
    
    # Step 3: Plot basic control totals for new cases and new deaths by month
    dfRaw %>%
        checkControl(groupBy=step3Group, useVars=step3Vals, printControls=FALSE, na.rm=TRUE) %>%
        helperLinePlot(x=step3Group, y="newValue", facetVar="name", facetScales="free_y", groupColor="name")
    
    # If there is no file for comparison, return the data
    if (is.null(dfRef) | if(length(dfRef)==1) is.na(dfRef) else FALSE) return(dfRaw)
    
    # Step 4b: Check similarity of existing and reference file
    # ovrWriteLog=FALSE since everything should be an append after the opening text line in step 0
    diffRaw <- checkSimilarity(df=dfRaw, 
                               ref=dfRef, 
                               keyVars=step4KeyVars, 
                               writeLog=writeLog, 
                               ovrwriteLog=FALSE
                               )
    
    # Step 5: Plot the similarity checks
    plotSimilarity(diffRaw, plotItems=step5PlotItems)
    
    # Step 6: Plot and report on differences in aggregates
    helperAggMap <- function(x) {
        h1 <- compareAggregate(df=dfRaw, ref=dfRef, grpVar=x$grpVar, numVars=x$numVars, 
                               sameUniverse=x$sameUniverse, plotData=x$plotData, isLine=x$isLine, 
                               returnDelta=x$returnDelta)
        if (isTRUE(x$flagLargeDelta)) {
            h2 <- flagLargeDelta(h1, pctTol=x$pctTol, absTol=x$absTol, sortBy=x$sortBy, 
                                 dropNA=x$dropNA, printAll=x$printAll
                                 )
            if (is.null(writeLog)) print(h2)
            else {
                cat(nrow(h2), " records", sep="")
                txt <- paste0("\n\n***Differences of at least ", 
                              x$absTol, 
                              " and at least ", 
                              round(100*x$pctTol, 3), "%\n\n"
                              )
                printLog(h2, txt=txt, writeLog=writeLog)
            }
        }
    }
    lapply(step6AggregateList, FUN=helperAggMap)
    
    cat("\n\n")
    
    # Return the raw data file
    dfRaw
    
}

# Explore for only reading and returning new data
testFile <- "./RInputFiles/Coronavirus/Weekly_United_States_COVID-19_Cases_and_Deaths_by_State.csv"
dfTest <- readQCRawCDCDaily(fileName=testFile, 
                            getData=FALSE, 
                            urlType="cdcWeekly",
                            url=c(),
                            vecRename=c("end_date"="date"),
                            selfList=list(),
                            fullList=list(),
                            uniqueBy=c("state", "date"), 
                            step3Group=c("date"), 
                            step3Vals=c("new_cases", "new_deaths"),
                            step4KeyVars=list("date"=list("label"="date", "countOnly"=TRUE, "convChar"=TRUE), 
                                              "state"=list("label"="state", "countOnly"=FALSE)
                                              ), # will need to update checkSimilarityMapper
                            step5PlotItems=c("date"),
                            step6AggregateList=list() # will need to update keyAggMapper
                            )
## 
## No file has been downloaded, will use existing file: ./RInputFiles/Coronavirus/Weekly_United_States_COVID-19_Cases_and_Deaths_by_State.csv
## Rows: 8820 Columns: 8
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr  (1): state
## dbl  (4): tot_cases, new_cases, tot_deaths, new_deaths
## date (3): date_updated, start_date, end_date
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
## 
## *** File has been checked for uniqueness by: state date

all.equal(dfTest, rename(tmpBurden, date=end_date))
## [1] TRUE

The function for processing downloaded data, without comparison to previous data, works as intended. Next steps are to update the appropriate mapping files to include “cdcWeeklyBurden” as an option, then check that the function runs as intended. Elements are added to the mapping list manually at first:

# Need to combine NYC as part of NY
lstComboMapper$cdcWeeklyBurden <- list("nyc"=list("comboVar"="state", 
                                                  "uqVars"="date", 
                                                  "vecCombo"=c("NY"="NY", "NYC"="NY"),
                                                  "fn"=specNA(sum)
                                                  )
                                       )

# Need to test URL mapping later
if("cdcWeeklyBurden" %in% names(urlMapper)) {
    urlMapper["cdcWeeklyBurden"] <- "https://data.cdc.gov/api/views/pwn4-m3yp/rows.csv?accessType=DOWNLOAD"
} else {
    origNames <- names(urlMapper)
    urlMapper <- c(urlMapper, "https://data.cdc.gov/api/views/pwn4-m3yp/rows.csv?accessType=DOWNLOAD")
    names(urlMapper) <- c(origNames, "cdcWeeklyBurden")
}
    

# Rename end_date to date
renMapper$cdcWeeklyBurden <- c('end_date'='date')

# No need for variable mapping (formats OK as-is)
selfListMapper$cdcWeeklyBurden <- list()
fullListMapper$cdcWeeklyBurden <- list()

# File should be unique by state-date
uqMapper$cdcWeeklyBurden <- c("state", "date")

# Keep only 50 states (after NYC mapping) and DC
lstFilterMapper$cdcWeeklyBurden <- list("state"=c(state.abb, "DC"))

# Keep date, state, tot_cases, new_cases, tot_deaths, new_deaths
vecSelectMapper$cdcWeeklyBurden <- c("date", "state", "tot_cases", "tot_deaths", "new_cases", "new_deaths")

# Checks for control groups
checkControlGroupMapper$cdcWeeklyBurden <- c("date")
checkControlVarsMapper$cdcWeeklyBurden <- c("new_cases", "new_deaths")

# Check for similarity mapping
checkSimilarityMapper$cdcWeeklyBurden <- list(date=list(label='date', countOnly=TRUE, convChar=TRUE), 
                                              state=list(label='state', countOnly=FALSE)
                                              )
plotSimilarityMapper$cdcWeeklyBurden <- c("date")

# Update keyAggMapper (use cdcDaily for now, probably need to update later)
keyAggMapper$cdcWeeklyBurden <- keyAggMapper$cdcDaily

# No variables need to be kept as-is (avoiding rolling 7-day)
asIsMapper$cdcWeeklyBurden <- c()

# No changes needed to perCapMapper or hhsMapper

# Run sample code
dfTest_v2 <- readQCRawCDCDaily(fileName=testFile, 
                               getData=FALSE, 
                               urlType="cdcWeeklyBurden",
                               url=c()
                               )
## 
## No file has been downloaded, will use existing file: ./RInputFiles/Coronavirus/Weekly_United_States_COVID-19_Cases_and_Deaths_by_State.csv
## Rows: 8820 Columns: 8
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr  (1): state
## dbl  (4): tot_cases, new_cases, tot_deaths, new_deaths
## date (3): date_updated, start_date, end_date
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
## 
## *** File has been checked for uniqueness by: state date

all.equal(dfTest, dfTest_v2)
## [1] TRUE

Next steps are to enable URL downloads and enable checking against a reference file. Downloading of new data is attempted:

# Run sample code
dfTest_v3 <- readQCRawCDCDaily(fileName="./RInputFiles/Coronavirus/CDC_dc_downloaded_221118.csv", 
                               getData=TRUE, 
                               urlType="cdcWeeklyBurden"
                               )
## Rows: 8880 Columns: 10
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr  (1): state
## dbl  (6): tot_cases, new_cases, tot_deaths, new_deaths, new_historic_cases, ...
## date (3): date_updated, start_date, end_date
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
## 
## *** File has been checked for uniqueness by: state date

dfTest_v3
## # A tibble: 8,880 × 10
##    date_updated state start_date date       tot_cases new_cases tot_de…¹ new_d…²
##    <date>       <chr> <date>     <date>         <dbl>     <dbl>    <dbl>   <dbl>
##  1 2020-01-23   AK    2020-01-16 2020-01-22         0         0        0       0
##  2 2020-01-30   AK    2020-01-23 2020-01-29         0         0        0       0
##  3 2020-02-06   AK    2020-01-30 2020-02-05         0         0        0       0
##  4 2020-02-13   AK    2020-02-06 2020-02-12         0         0        0       0
##  5 2020-02-20   AK    2020-02-13 2020-02-19         0         0        0       0
##  6 2020-02-27   AK    2020-02-20 2020-02-26         0         0        0       0
##  7 2020-03-05   AK    2020-02-27 2020-03-04         0         0        0       0
##  8 2020-03-12   AK    2020-03-05 2020-03-11         0         0        0       0
##  9 2020-03-19   AK    2020-03-12 2020-03-18        11        11        0       0
## 10 2020-03-26   AK    2020-03-19 2020-03-25        63        52        1       1
## # … with 8,870 more rows, 2 more variables: new_historic_cases <dbl>,
## #   new_historic_deaths <dbl>, and abbreviated variable names ¹​tot_deaths,
## #   ²​new_deaths
## # ℹ Use `print(n = ...)` to see more rows, and `colnames()` to see all variable names

Checking against a reference file is also enabled:

dfTest_v3_ref <- readQCRawCDCDaily(fileName="./RInputFiles/Coronavirus/CDC_dc_downloaded_221118.csv", 
                                   getData=FALSE,
                                   dfRef=dfTest_v2,
                                   urlType="cdcWeeklyBurden"
                                   )
## 
## No file has been downloaded, will use existing file: ./RInputFiles/Coronavirus/CDC_dc_downloaded_221118.csv
## Rows: 8880 Columns: 10
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr  (1): state
## dbl  (6): tot_cases, new_cases, tot_deaths, new_deaths, new_historic_cases, ...
## date (3): date_updated, start_date, end_date
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
## 
## *** File has been checked for uniqueness by: state date

## 
## 
## Checking for similarity of: column names
## In reference but not in current: 
## In current but not in reference: new_historic_cases new_historic_deaths
## 
## Checking for similarity of: date
## In reference but not in current: 0
## In current but not in reference: 1
## 
## Checking for similarity of: state
## In reference but not in current: 
## In current but not in reference:

## 
## 
## ***Differences of at least 5 and at least 5%
## 
##         date      name newValue refValue absDelta   pctDelta
## 1 2020-02-26 tot_cases       71       83       12 0.15584416
## 2 2020-03-04 tot_cases      183      201       18 0.09375000
## 3 2020-03-11 tot_cases     1352     1427       75 0.05397625
## 4 2020-02-26 new_cases       24       31        7 0.25454545
## 5 2020-03-04 new_cases      112      118        6 0.05217391

## 
## 
## ***Differences of at least 0 and at least 0.1%
## 
##   state       name  newValue  refValue absDelta    pctDelta
## 1   FSM  tot_cases    206651    206993      342 0.001653596
## 2    PA  tot_cases 205201857 205436071   234214 0.001140732
## 3    CO new_deaths     13497     13473       24 0.001779755
## 4    OH new_deaths     40208     40249       41 0.001019178
## 5   FSM  new_cases     22032     22203      171 0.007731434
## 6    KY  new_cases   1622400   1619549     2851 0.001758819
dfTest_v3_ref
## # A tibble: 8,880 × 10
##    date_updated state start_date date       tot_cases new_cases tot_de…¹ new_d…²
##    <date>       <chr> <date>     <date>         <dbl>     <dbl>    <dbl>   <dbl>
##  1 2020-01-23   AK    2020-01-16 2020-01-22         0         0        0       0
##  2 2020-01-30   AK    2020-01-23 2020-01-29         0         0        0       0
##  3 2020-02-06   AK    2020-01-30 2020-02-05         0         0        0       0
##  4 2020-02-13   AK    2020-02-06 2020-02-12         0         0        0       0
##  5 2020-02-20   AK    2020-02-13 2020-02-19         0         0        0       0
##  6 2020-02-27   AK    2020-02-20 2020-02-26         0         0        0       0
##  7 2020-03-05   AK    2020-02-27 2020-03-04         0         0        0       0
##  8 2020-03-12   AK    2020-03-05 2020-03-11         0         0        0       0
##  9 2020-03-19   AK    2020-03-12 2020-03-18        11        11        0       0
## 10 2020-03-26   AK    2020-03-19 2020-03-25        63        52        1       1
## # … with 8,870 more rows, 2 more variables: new_historic_cases <dbl>,
## #   new_historic_deaths <dbl>, and abbreviated variable names ¹​tot_deaths,
## #   ²​new_deaths
## # ℹ Use `print(n = ...)` to see more rows, and `colnames()` to see all variable names

New columns have been added to explain jumps in total cases/deaths that are not explained by that week’s reported new cases/deaths. These data are explored:

# Full file
testFull <- read_csv("./RInputFiles/Coronavirus/CDC_dc_downloaded_221118.csv")
## Rows: 8880 Columns: 10
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr  (1): state
## dbl  (6): tot_cases, new_cases, tot_deaths, new_deaths, new_historic_cases, ...
## date (3): date_updated, start_date, end_date
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
# Entries with non-zero for "new_historic_*"
testFull %>%
    filter(new_historic_cases != 0 | new_historic_deaths != 0)
## # A tibble: 5 × 10
##   date_upd…¹ state start_date end_date   tot_c…² new_c…³ tot_d…⁴ new_d…⁵ new_h…⁶
##   <date>     <chr> <date>     <date>       <dbl>   <dbl>   <dbl>   <dbl>   <dbl>
## 1 2022-10-27 DC    2022-10-20 2022-10-26  169709     273    1392      -5       0
## 2 2022-11-10 DC    2022-11-03 2022-11-09  170482     441    1402       0       0
## 3 2022-09-29 KS    2022-09-22 2022-09-28  879001    2780    9554       7       0
## 4 2022-11-03 KS    2022-10-27 2022-11-02  890598    2388    9620      12       0
## 5 2022-10-27 NYC   2022-10-20 2022-10-26 2928439   14590   42863      91       0
## # … with 1 more variable: new_historic_deaths <dbl>, and abbreviated variable
## #   names ¹​date_updated, ²​tot_cases, ³​new_cases, ⁴​tot_deaths, ⁵​new_deaths,
## #   ⁶​new_historic_cases
## # ℹ Use `colnames()` to see all variable names
# Cases where cumsum and total are not equal
testFull %>%
    arrange(state, end_date) %>% 
    group_by(state) %>% 
    mutate(delta=tot_deaths-cumsum(new_deaths)) %>% 
    filter(delta != 0)
## # A tibble: 16 × 11
## # Groups:   state [3]
##    date_updated state start_date end_date   tot_cases new_cases tot_de…¹ new_d…²
##    <date>       <chr> <date>     <date>         <dbl>     <dbl>    <dbl>   <dbl>
##  1 2022-10-27   DC    2022-10-20 2022-10-26    169709       273     1392      -5
##  2 2022-11-03   DC    2022-10-27 2022-11-02    170041       332     1397       5
##  3 2022-11-10   DC    2022-11-03 2022-11-09    170482       441     1402       0
##  4 2022-11-17   DC    2022-11-10 2022-11-16    170750       268     1403       1
##  5 2022-09-29   KS    2022-09-22 2022-09-28    879001      2780     9554       7
##  6 2022-10-06   KS    2022-09-29 2022-10-05    880633      1632     9573      19
##  7 2022-10-13   KS    2022-10-06 2022-10-12    883482      2849     9590      17
##  8 2022-10-20   KS    2022-10-13 2022-10-19    886123      2641     9601      11
##  9 2022-10-27   KS    2022-10-20 2022-10-26    888210      2087     9607       6
## 10 2022-11-03   KS    2022-10-27 2022-11-02    890598      2388     9620      12
## 11 2022-11-10   KS    2022-11-03 2022-11-09    893300      2702     9626       6
## 12 2022-11-17   KS    2022-11-10 2022-11-16    895776      2476     9652      26
## 13 2022-10-27   NYC   2022-10-20 2022-10-26   2928439     14590    42863      91
## 14 2022-11-03   NYC   2022-10-27 2022-11-02   2944270     15831    42880      17
## 15 2022-11-10   NYC   2022-11-03 2022-11-09   2962479     18209    42957      77
## 16 2022-11-17   NYC   2022-11-10 2022-11-16   2979932     17453    43033      76
## # … with 3 more variables: new_historic_cases <dbl>, new_historic_deaths <dbl>,
## #   delta <dbl>, and abbreviated variable names ¹​tot_deaths, ²​new_deaths
## # ℹ Use `colnames()` to see all variable names

The field appears to be working as intended. Next steps are to compare the cases and deaths data to the previous daily data files:

# Conversion of raw CDC daily data to cumsum
cdcDailyTest <- cdc_daily_221102$dfRaw$cdcDaily %>%
    select(date, state, new_cases, new_deaths) %>%
    arrange(state, date) %>%
    group_by(state) %>%
    mutate(cum_cases=cumsum(new_cases), cum_deaths=cumsum(new_deaths)) %>%
    ungroup()

# Integration of new weekly data, using end_date=date
testCombo <- testFull %>%
    select(date=end_date, state, wkly_tot_cases=tot_cases, wkly_tot_deaths=tot_deaths) %>%
    left_join(cdcDailyTest, by=c("date", "state"))
testCombo
## # A tibble: 8,880 × 8
##    date       state wkly_tot_cases wkly_tot_de…¹ new_c…² new_d…³ cum_c…⁴ cum_d…⁵
##    <date>     <chr>          <dbl>         <dbl>   <dbl>   <dbl>   <dbl>   <dbl>
##  1 2020-01-22 AK                 0             0       0       0       0       0
##  2 2020-01-29 AK                 0             0       0       0       0       0
##  3 2020-02-05 AK                 0             0       0       0       0       0
##  4 2020-02-12 AK                 0             0       0       0       0       0
##  5 2020-02-19 AK                 0             0       0       0       0       0
##  6 2020-02-26 AK                 0             0       0       0       0       0
##  7 2020-03-04 AK                 0             0       0       0       0       0
##  8 2020-03-11 AK                 0             0       0       0       0       0
##  9 2020-03-18 AK                11             0       5       0       8       1
## 10 2020-03-25 AK                63             1       7       0      49       1
## # … with 8,870 more rows, and abbreviated variable names ¹​wkly_tot_deaths,
## #   ²​new_cases, ³​new_deaths, ⁴​cum_cases, ⁵​cum_deaths
## # ℹ Use `print(n = ...)` to see more rows
# Calculation of RMSE by state for 'tot_deaths'
testCombo %>%
    filter(date <= "2022-10-12") %>%
    mutate(delta=wkly_tot_deaths-cum_deaths) %>%
    group_by(state) %>%
    summarize(rmse=sqrt(mean(delta**2)), r2=1-rmse/mean(cum_deaths)) %>%
    filter(state %in% c(state.abb, "DC", "NYC")) %>%
    ggplot(aes(x=fct_reorder(state, r2), y=r2)) + 
    geom_col(fill="lightblue") + 
    geom_text(aes(label=round(r2, 2)), hjust=0) +
    coord_flip() + 
    labs(x=NULL, y="Similarity of reported deaths (weekly vs. daily)\n(1.0 means perfect alignment)")

# Select states plotted
testCombo %>%
    filter(state %in% c("OR", "LA", "DC", "PA", "NE", "WA", "OH", "MO", "AK")) %>%
    select(date, state, wkly_tot_deaths, cum_deaths) %>%
    pivot_longer(-c(state, date)) %>%
    ggplot(aes(x=date, y=value)) + 
    geom_line(aes(group=name, 
                  color=c("wkly_tot_deaths"="Weekly data (new)", "cum_deaths"="Daily data (old)")[name]
                  )
              ) + 
    facet_wrap(~state, scales="free_y") + 
    scale_color_discrete("Source:") + 
    labs(title="Comparison of cumulative deaths by source", y="Cumulative deaths", x=NULL)
## Warning: Removed 5 row(s) containing missing values (geom_path).

# Overall data
testCombo %>%
    filter(state %in% c(state.abb, "DC", "NYC")) %>%
    group_by(date) %>%
    summarize(across(where(is.numeric), specNA())) %>%
    select(date, wkly_tot_deaths, cum_deaths) %>%
    pivot_longer(-c(date)) %>%
    ggplot(aes(x=date, y=value)) + 
    geom_line(aes(group=name, 
                  color=c("wkly_tot_deaths"="Weekly data (new)", "cum_deaths"="Daily data (old)")[name]
                  )
              ) + 
    scale_color_discrete("Source:") + 
    labs(title="Comparison of cumulative deaths by source", 
         y="Cumulative deaths", 
         x=NULL, 
         subtitle="50 states plus DC"
         )
## Warning: Removed 5 row(s) containing missing values (geom_path).

Alignment of reported deaths varies by state. In aggregate, the newer data appears to report slightly more deaths. The data file is processed using the existing function:

dfTestProcess <- processRawFile(dfTest_v3_ref, 
                                vecRename=c(), 
                                vecSelect=vecSelectMapper[["cdcWeeklyBurden"]], 
                                lstCombo=lstComboMapper[["cdcWeeklyBurden"]],
                                lstFilter=lstFilterMapper[["cdcWeeklyBurden"]]
                                )
## 
## Column sums before and after applying filtering rules:
## # A tibble: 3 × 6
##   isType tot_cases tot_deaths     new_cases    new_deaths        n
##   <chr>      <dbl>      <dbl>         <dbl>         <dbl>    <dbl>
## 1 before   6.09e+9    8.48e+7 98174364      1072078       8732    
## 2 after    6.04e+9    8.44e+7 97030505      1066086       7548    
## 3 pctchg   7.56e-3    4.72e-3        0.0117       0.00559    0.136
dfTestProcess
## # A tibble: 7,548 × 6
##    date       state tot_cases tot_deaths new_cases new_deaths
##    <date>     <chr>     <dbl>      <dbl>     <dbl>      <dbl>
##  1 2020-01-22 AK            0          0         0          0
##  2 2020-01-29 AK            0          0         0          0
##  3 2020-02-05 AK            0          0         0          0
##  4 2020-02-12 AK            0          0         0          0
##  5 2020-02-19 AK            0          0         0          0
##  6 2020-02-26 AK            0          0         0          0
##  7 2020-03-04 AK            0          0         0          0
##  8 2020-03-11 AK            0          0         0          0
##  9 2020-03-18 AK           11          0        11          0
## 10 2020-03-25 AK           63          1        52          1
## # … with 7,538 more rows
## # ℹ Use `print(n = ...)` to see more rows